protected void gridDraft_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { Int32 MsgId = 0; DataTable dtMain = new DataTable(); MsgId = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "MsgId").ToString()); dtMain = new DataTable(); dtMain = clsMessage.SelectMsgDetailforDraftPartyList(MsgId); Label sentTo = (Label)e.Row.FindControl("lblSentTo"); if (dtMain.Rows.Count > 0) { String ToList = ""; int i = 0; foreach (DataRow DR in dtMain.Rows) { if (i >= 1) { ToList = ToList + " , " + DR["Compname"].ToString(); } if (i == 0) { ToList = DR["Compname"].ToString(); i = 1; } if (ToList.Length > 25) { ToList = ToList + " ...."; break; } } sentTo.Text = ToList.ToString(); } dtMain = new DataTable(); dtMain = clsMessage.SelectMsgforFileAttach(MsgId); Image img = (Image)e.Row.FindControl("ImgFile"); if (dtMain.Rows.Count > 0) { img.ImageUrl = "~/Account/images/attach.png"; img.Visible = true; } else { img.ImageUrl = ""; img.Visible = false; } } try { if (gridDraft.Rows.Count > 0) { CheckBox cbHeader = (CheckBox)gridDraft.HeaderRow.FindControl("HeaderChkbox"); cbHeader.Attributes["onclick"] = "ChangeAllCheckBoxStates(this.checked);"; List <string> ArrayValues = new List <string>(); ArrayValues.Add(string.Concat("'", cbHeader.ClientID, "'")); foreach (GridViewRow gvr in gridDraft.Rows) { CheckBox cb = (CheckBox)gvr.FindControl("chkMsg"); cb.Attributes["onclick"] = "ChangeHeaderAsNeeded();"; ArrayValues.Add(string.Concat("'", cb.ClientID, "'")); } CheckBoxIDsArray.Text = "<script type='text/javascript'>" + "\n" + "<!--" + "\n" + String.Concat("var CheckBoxIDs = new Array(", String.Join(",", ArrayValues.ToArray()), ");") + "\n // -->" + "\n" + "</script>"; } else { } } catch (Exception ex) { pnlmsg.Visible = true; lblmsg.Text = "Error in databound : " + ex.Message.ToString(); } }