Tuesday, June 10, 2014

C#.NET - Adding "SELECT" in Combo box

private void LoadCommentType()
        {
            try
            {
                DataTable dtCommentType = clsCommon.oAdmin.dtGetCommentType();
                if (dtCommentType != null)
                {
                    DataRow dr = dtCommentType.NewRow();
                    dr["CommentTypeId"] = 0;
                    dr["CommentTypeName"] = "--Select--";
                    dtCommentType.Rows.InsertAt(dr, 0);

                    cboComment.DisplayMember = "CommentTypeName";
                    cboComment.ValueMember = "CommentTypeId";
                    cboComment.DataSource = dtCommentType.DefaultView;
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex.ToString());
            }

        }

No comments:

Post a Comment