For the life of me I cant figure out why using this code:
Code:
Private Sub DataGrid1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGrid1.SelectedIndexChanged
Label1.Text = DataGrid1.SelectedItem.Cells(7).Text
End Sub
produces this error:
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:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index]
System.Web.UI.ControlCollection.get_Item(Int32 index) +58
System.Web.UI.WebControls.TableCellCollection.get_ Item(Int32 index) +22
DR.WebForm1.DataGrid1_SelectedIndexChanged(Object sender, EventArgs e) in Z:\Inetpub\wwwroot\New Intranet\Medecine\DR\WebForm1.aspx.
vb:170
System.Web.UI.WebControls.BaseDataList.OnSelectedI ndexChanged(EventArgs e) +108
System.Web.UI.WebControls.DataGrid.OnBubbleEvent(O bject source, EventArgs e) +159
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26
System.Web.UI.WebControls.DataGridItem.OnBubbleEve nt(Object source, EventArgs e) +100
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26
System.Web.UI.WebControls.LinkButton.OnCommand(Com mandEventArgs e) +120
System.Web.UI.WebControls.LinkButton.System.Web.UI .IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +115
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +138
System.Web.UI.Page.ProcessRequestMain() +1292
This datagrid is bound to a stored procedure filled dataset at runtime. I have tried to get data out of every cell in the grid, and only cell(0)( the select Button) does not .....never mind .....