Hello All.
I am having a problem
In my source code i connected with MS access database
and i am using datagrid and trying to edit and delete the record.
but it's giving Index out of range error.
i am using MS access first time
is there any other method to use datagrid with MS access database .
I am very confused
Please solve my problem ....
Loading

Amit ChoudharyRank #145 · 15.8K reputationPosted Mar 3, 2010, 12:00 AM EST
Please post the error with stack trace.... i can help you
kiran kumarRank #3,110 · 461 reputationPosted Mar 2, 2010, 11:49 PM EST
tanu9 reputationPosted Mar 3, 2010, 12:16 AM EST
First of all thx for reply..
this is the stack trace ..
u can check like this or i should upload the full code??
thx again
[ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index] System.Collections.ArrayList.get_Item(Int32 index) +2880797 System.Web.UI.WebControls.DataKeyCollection.get_Item(Int32 index) +9 asccess_connection._Default.DataGrid1_DeleteCommand(Object source, DataGridCommandEventArgs e) in E:\tanu_asp\asccess_connection\asccess_connection\Default.aspx.cs:103 System.Web.UI.WebControls.DataGrid.OnDeleteCommand(DataGridCommandEventArgs e) +105 System.Web.UI.WebControls.DataGrid.OnBubbleEvent(Object source, EventArgs e) +537 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35 System.Web.UI.WebControls.DataGridItem.OnBubbleEvent(Object source, EventArgs e) +117 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35 System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +115 System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +132 System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +177 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746tanu9 reputationPosted Mar 3, 2010, 12:19 AM EST
I am sending my whole code with database..
Please check it and tell me where i m wrong.?
thanks.
Amit ChoudharyRank #145 · 15.8K reputationPosted Mar 3, 2010, 1:04 AM EST
my guess was right after seeing your code i have doubt on the line where you are accessing the datakey....
after looking at your code inside the project found the error that you did'nt specify the DatakeyField value in your Grid.
oncancelcommand="DataGrid1_CancelCommand" DataKeyField="ID" oneditcommand="DataGrid1_EditCommand"
onupdatecommand="DataGrid1_UpdateCommand"
ondeletecommand="DataGrid1_DeleteCommand"
onpageindexchanged="DataGrid1_PageIndexChanged"
AutoGenerateColumns=false Height="290px" Width="437px">
Add this attribute value as above. and your error get resolved.
Please don't forget to mark the answer.
tanu9 reputationPosted Mar 3, 2010, 1:28 AM EST
thanks a lot..
i totally forget abt that ..
thx a lot....
tanu9 reputationPosted Mar 3, 2010, 1:28 AM EST
thanks a lot..
i totally forget abt that ..
thx a lot....
Amit ChoudharyRank #145 · 15.8K reputationPosted Mar 3, 2010, 3:08 AM EST
Always mark the post as answer if it helps you. It benefit others to get the quick solution for resembling problems.
Best regards