Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Edit/Update/Cancel Problem

Reply
Thread Tools

Edit/Update/Cancel Problem

 
 
mschmidt18@gmail.com
Guest
Posts: n/a
 
      07-10-2006
Hello,

I have a datagrid (.net 1.1) with an edit/update/cancel column. I am
having trouble capturing the data when the update event fires. It is
getting whatever was in the textbox before it was changed.

Here is some of my code:

c#

System.Web.UI.WebControls.TextBox p_productDesc = new
System.Web.UI.WebControls.TextBox();
p_productDesc = (System.Web.UI.WebControls.TextBox)
e.Item.Cells[3].Controls[0];
.....
sp[0] = new SqlParameter("@productId",e.Item.ItemIndex);
sp[1] = new SqlParameter("@productDesc",p_productDesc.Text.ToS tring());


I also need help with the ItemIndex. I am using paging and it doesnt
seem to be working right, I need the true ID of the row.

If you need to see more code, just ask! Thanks!

 
Reply With Quote
 
 
 
 
Scott M.
Guest
Posts: n/a
 
      07-10-2006
You need to find the row index for the underlying DataTable that the grid is
working off of, not the row index from the grid.

You'll need to do someting like this:

[VB.NET]

Dim dataSetRow As DataRow = dataSet.Tables(0).Select("PrimaryKey =" &
CType(e.Item.FindControl("theTextboxName",Textbox) .Text(0)


Now, dataSetRow represents the row in your DataSet that contains the data
being edited.
So, you can just look at whatever field in that row you want.

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hello,
>
> I have a datagrid (.net 1.1) with an edit/update/cancel column. I am
> having trouble capturing the data when the update event fires. It is
> getting whatever was in the textbox before it was changed.
>
> Here is some of my code:
>
> c#
>
> System.Web.UI.WebControls.TextBox p_productDesc = new
> System.Web.UI.WebControls.TextBox();
> p_productDesc = (System.Web.UI.WebControls.TextBox)
> e.Item.Cells[3].Controls[0];
> ....
> sp[0] = new SqlParameter("@productId",e.Item.ItemIndex);
> sp[1] = new SqlParameter("@productDesc",p_productDesc.Text.ToS tring());
>
>
> I also need help with the ItemIndex. I am using paging and it doesnt
> seem to be working right, I need the true ID of the row.
>
> If you need to see more code, just ask! Thanks!
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem problem problem :( Need Help Mike ASP General 2 05-11-2004 08:36 AM



Advertisments