Gridview Row created Event
-
-
I used gridviewrowcreated event in order to create a heading row for the grid First time it executes well after that for every event that is fired on the page the control is coming directly the gridviewrowcreated event How can i solve this problem?
-
It is hard to assume the problem from your obscure post. Do you want write some code that should execute only when the creation of header row? Then you should write it in an "if" block which checks the row type is header row.
if (e.Row.RowType == DataControlRowType.Header) { //Build custom header. GridView gvGrid = (GridView)sender; GridViewRow gvRow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert); TableCell tblCell = new TableCell(); TableCell tblCell1 = new TableCell(); //Add Department tblCell.Text = "Attendance Report From:" + Convert.ToDateTime(sFromDate.ToString()).ToString("dd/MM/yyyy") + "-" + "To" + Convert.ToDateTime(sToDate.ToString()).ToString("dd/MM/yyyy"); tblCell.ColumnSpan = 6; tblCell.ForeColor = System.Drawing.Color.Black; tblCell.Font.Bold = true; tblCell.Font.Size = 14; gvRow.Cells.Add(tblCell); tblCell.HorizontalAlign = HorizontalAlign.Left; gvGrid.Controls[0].Controls.AddAt(0, gvRow); } I used this code first time it executes well after that when any event is fired on the page the control comes to this rowcreated event its not even entering into page_load and all the text in the textbox controls were being cleared
modified on Thursday, October 8, 2009 12:42 AM
-
if (e.Row.RowType == DataControlRowType.Header) { //Build custom header. GridView gvGrid = (GridView)sender; GridViewRow gvRow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert); TableCell tblCell = new TableCell(); TableCell tblCell1 = new TableCell(); //Add Department tblCell.Text = "Attendance Report From:" + Convert.ToDateTime(sFromDate.ToString()).ToString("dd/MM/yyyy") + "-" + "To" + Convert.ToDateTime(sToDate.ToString()).ToString("dd/MM/yyyy"); tblCell.ColumnSpan = 6; tblCell.ForeColor = System.Drawing.Color.Black; tblCell.Font.Bold = true; tblCell.Font.Size = 14; gvRow.Cells.Add(tblCell); tblCell.HorizontalAlign = HorizontalAlign.Left; gvGrid.Controls[0].Controls.AddAt(0, gvRow); } I used this code first time it executes well after that when any event is fired on the page the control comes to this rowcreated event its not even entering into page_load and all the text in the textbox controls were being cleared
modified on Thursday, October 8, 2009 12:42 AM
-
if (e.Row.RowType == DataControlRowType.Header) { //Build custom header. GridView gvGrid = (GridView)sender; GridViewRow gvRow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert); TableCell tblCell = new TableCell(); TableCell tblCell1 = new TableCell(); //Add Department tblCell.Text = "Attendance Report From:" + Convert.ToDateTime(sFromDate.ToString()).ToString("dd/MM/yyyy") + "-" + "To" + Convert.ToDateTime(sToDate.ToString()).ToString("dd/MM/yyyy"); tblCell.ColumnSpan = 6; tblCell.ForeColor = System.Drawing.Color.Black; tblCell.Font.Bold = true; tblCell.Font.Size = 14; gvRow.Cells.Add(tblCell); tblCell.HorizontalAlign = HorizontalAlign.Left; gvGrid.Controls[0].Controls.AddAt(0, gvRow); } I used this code first time it executes well after that when any event is fired on the page the control comes to this rowcreated event its not even entering into page_load and all the text in the textbox controls were being cleared
modified on Thursday, October 8, 2009 12:42 AM
try to keep the breakpoint on all the events which are present in the code page..!Then try to debug the page You can find the error..!
MyFirstArticlePublished: MenuControlSelectedItem Why Do Some People Forget To Mark as Answer .If It Helps.
-
try to keep the breakpoint on all the events which are present in the code page..!Then try to debug the page You can find the error..!
MyFirstArticlePublished: MenuControlSelectedItem Why Do Some People Forget To Mark as Answer .If It Helps.