Hi All
I am populating a grid at runtime/on-the-fly which is fine.
But when I want to get a value of a check-box in the grid I am getting error.
I can't use the findcontrol as it doesn't exist for any of the controls.
Please help me.
CodeBehind:-
Code:
protectedvoid GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
bool att = false;
GridViewRow gvrow = GridView1.Rows[e.RowIndex];
CheckBox chk_SelectCheckbox = (CheckBox)gvrow.Cells[4].Controls[1]; //checkbox to capture chkbox selection
}
Error screenshot
Server Error in '/Event' Application.
Specified argument was out of the range of valid values.
Parameter name: index
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index
Source Error:
Line 135: bool att = false;Line 136: GridViewRow gvrow = GridView1.Rows[e.RowIndex];Line 137: CheckBox chk_SelectCheckbox = (CheckBox)gvrow.Cells[4].Controls[1]; //checkbox to capture chkbox selectionLine 138: Line 139:
Source File: c:\Documents\Visual Studio 2008\Event\UpdateAttendance.aspx.cs Line: 137
Stack Trace:
[ArgumentOutOfRangeException: Specified argument was out of the range of valid values.Parameter name: index] System.Web.UI.ControlCollection.get_Item(Int32 index) +8668910 UpdateAttendance.GridView1_RowUpdating(Object sender, GridViewUpdateEventArgs e) in c:\Users\Mayur\Desktop\Data\urvashi\Documents\Visu al Studio 2008\IndianSpeedDating\UpdateAttendance.aspx.cs:13 7 System.Web.UI.WebControls.GridView.OnRowUpdating(G ridViewUpdateEventArgs e) +133 System.Web.UI.WebControls.GridView.HandleUpdate(Gr idViewRow row, Int32 rowIndex, Boolean causesValidation) +720 System.Web.UI.WebControls.GridView.HandleEvent(Eve ntArgs e, Boolean causesValidation, String validationGroup) +704 System.Web.UI.WebControls.GridView.OnBubbleEvent(O bject source, EventArgs e) +95 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37 System.Web.UI.WebControls.GridViewRow.OnBubbleEven t(Object source, EventArgs e) +123 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37 System.Web.UI.WebControls.LinkButton.OnCommand(Com mandEventArgs e) +118 System.Web.UI.WebControls.LinkButton.RaisePostBack Event(String eventArgument) +135 System.Web.UI.WebControls.LinkButton.System.Web.UI .IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +175 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
Version Information: Microsoft .NET Framework Version:2.0.50727.3074; ASP.NET Version:2.0.50727.3074