iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
I have a webgrid bound to a sqldatasource. The sqldatasource has SelectCommand, InsertCommand, DeleteCommand and UpdateCommand defined. Whenever I update a row, I get the object reference error. Select, Insert and Delete all work fine. My code is listed below:
Any help wpuld be greatly appreciated. I've read many posts on the Developer Network, but none actually listed an answer.
Thanks,
Conrad
Hi Conrad,
Sorry, but I must be forgot to attach the file, apologize for that. In my sample, everything works just fine and I added the DataKeyField to the RootTable element as well. However, it cause no problem at all.
I believe that our WebGrid supports Oracle database as well, so it will not make any different. Thank you.
Best Regards,
Andi Santoso
The code that you have provided is almost correct, however, you are missing a little thing. Here is the snippet to reference the n-index column in the grid. In here, I am going to display it on TextBox that is why I have to convert the value into a string by .ToString().
TextBox1.Text = e.Row.Cells[1].Value.ToString();
I hope it helps and please, do not heistate to ask if you have any other questions. Thank you.
Sorry, but I am not able to repro your issue. I have tried to create a WebGrid using your setting and Northwind SQL database, and the update row works just fine. Here, I attached you my sample file. There might be a workaround for this, but I am not quite sure if it is working or not since I can not repro your issue. Try to add the RootTable DataKeyFiled within your WebGrid. Here the snippet:
<RootTable DataKeyField="HARDWARE_SCHED_CODE" ColumnHeaders="Yes" AllowEdit="Yes" AllowDelete="Yes">
I hope it helps and let me know if it solves your issue. Thank you.
Andi,
I added the DataKeyField to the RootTable element and it caused problems with the Insert and I still get the same message on Update. Oracle is the database I'm updating. Will that make a difference?
Also, I couldn't find the attachment.
Hi Andi,
In reference to the code above, in the WebGrid1_UpdateRow code, I'm trying to reference the second column in the grid. I can reference the first with the code:
e.Rows.Cells(0).value
however when I try to reference the second column with:
e.Rows.Cells(1).Value
I get the dreaded object reference error message.
What am I doing wrong?
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname