DataSet.Tables[IndexOfTable].Rows[IndexOfRow] should do it for you. From
that exception, it looks like the table doesn't have any rows.
Before you call your function, do a Debug.Assert(DataTable.Rows.Count > 0)
and see what happens.
"Will" <(E-Mail Removed)> wrote in message
news:56DE29CD-35AF-42A1-803F-(E-Mail Removed)...
> How do I get a datarow from a dataset? I have a datagrid and want to pass
the selected datagrid row selected for update to another class to do
validation. I get the following exception:
>
> There is no row at position 0.
> 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.IndexOutOfRangeException: There is no row at
position 0.
>
> Source Error:
>
>
> Line 158: 'Dim lViewState As System.Web.UI.StateBag = Me.ViewState
> Line 159: 'mDataRow =
Me.DsNorthWind_CustOrders1.Tables(0).Rows.Item(mRowIndex)
> Line 160: mDataRow =
Me.DsNorthWind_CustOrders1.Tables(0).Rows(mRowIndex)
> Line 161: 'send rowindex & datarow to ActivateRule for validation
> Line 162: mActRule.Validate(mRowIndex, mDataRow)
>
>
> Source File: c:\inetpub\wwwroot\ExceptionBeta\WebForm1.aspx.vb Line:
160
>
> Stack Trace:
>
>
> [IndexOutOfRangeException: There is no row at position 0.]
> System.Data.DataRowCollection.get_Item(Int32 index)
> ExceptionBeta.WebForm1.UpdateCommandEventHandler(Object sender,
DataGridCommandEventArgs e) in
c:\inetpub\wwwroot\ExceptionBeta\WebForm1.aspx.vb:160
>
System.Web.UI.WebControls.DataGrid.OnUpdateCommand(DataGridCommandEventArgs
e)
> System.Web.UI.WebControls.DataGrid.OnBubbleEvent(Object source,
EventArgs e)
> System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
> System.Web.UI.WebControls.DataGridItem.OnBubbleEvent(Object source,
EventArgs e)
> System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
> System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e)
>
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.Rai
sePostBackEvent(String eventArgument)
> System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
> System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
> System.Web.UI.Page.ProcessRequestMain()
>
>
>
>
|