Get the row that an object is contained in

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello all,

I have a datagrid that I dynamically add rows to (through binding to a
datatable). Each row has a textbox that a user can enter a value into and a
couple of other columns with values.

I have the textbox autopostback set to true so that I can capture the text
changed event. What I need to do in that event is get data from another
column in the same row as the textbox that was changed, but I'm not sure how
I know or how I would find out what the row is.

I've accessed the entered value of the textbox through the sender, but now
what?

TIA,
Melissa
 
I'd check the ClientID or UniqueID of the sender control. Maybe this may
give you some ideas.
BTW, how did you create the textboxes? Did you use <asp:TemplateColumn>? In
that case you might want to preset the textboxes's IDs using ID='<%#
"txt"+DataBinder.Eval(Container.DataItem,....)%>'. This way you can easily
identify the row later using source.ID.SubString(3).

HTH,
Axel Dahmen
 

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

Back
Top