Home All Groups Group Topic Archive Search About

Interrogating cells on current row for GridView

Author
1 Jul 2006 3:54 AM
LuLu
Greetings all -
   Might some kind, knowledgeable soul know how to determine the contents of
a particular cell within a GridView control when the procedure specified  in
"OnTextChanged" is fired?

<asp:TextBox ID="txtQuantity" runat="server" Text='<%# Bind("Quantity") %>'
OnTextChanged="QuantityChanged" AutoPostBack ="true" ></asp:TextBox>

The procedure QuantityChanged gets fired OK, but I'm at a loss to determine
which row the user is editing, and the values of cells in that particular row.
Note - I can't use the RowEditing or RowUpdating commands, because the
datasource for the grid is bound at run time, and there is no primary key.
Neither would the "Selected" events fire, because I don't want the user to
have to click on "select" or "edit" - this really needs to hapen through
OnTextChanged.  The grid works great, the trick now is determining through
the GridView properties the current row, and the values of particular cells
in that row.  Something like:

RetrievedValue = gridShoppingCart.Rows([???]).Cells([???]).????

Kind thanks in advance to the gracious person willing to help!
CindyLu

Author
1 Jul 2006 6:41 AM
ReyN
Hello LuLu

To get the row currently in edit mode

GridViewRow row = gridShoppingCart.Rows [ gridShoppingCart.EditIndex ];

To get the values in the row:

for BoundField

row.Cells [ x ].Text

for other field types

row.Cells [ x ].Controls [ x ].Text