protected void EditLinkButton_OnClick(object sender, EventArgs e) { try { LinkButton lnkBtn = (LinkButton)sender; GridViewRow row = (GridViewRow)lnkBtn.NamingContainer; hdbFieldId.Value = gridviewInitialDataElement.Rows[row.RowIndex].Cells[0].Text.ToString(); initialDataBLL initialData = new initialDataBLL(); initialData.ElementDataId = hdbFieldId.Value; DataTable dt = initialData.GetElementDataById(); if (dt.Rows.Count > 0) { txtbxElementName.Text = dt.Rows[0]["ElementName"].ToString(); txtbxDescription.Text = dt.Rows[0]["Suffix"].ToString(); ddlGroup.SelectedValue = dt.Rows[0]["ElementGrpId"].ToString();; } btnSave.Text = "Update"; } catch (Exception ex) { msgbox.Attributes.Add("Class", "alert alert-warning"); msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = ex.Message; } }