Edit/Update/Cancel Problem

M

mschmidt18

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.ToString());


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!
 
S

Scott M.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top