Hello Everybody!

I have a simple question: where can I get or set a control, which is in a template field?

I have a gridview, and I've created a templatefield in it, with a textbox inside. I want to use the data typed in that textbox, but I don't know how to reach it.

I've tried the following:

GridView1.SelectedRow.Cells[4]. how to continue? Looked for everywhere, but no sign of it.

(The textbox is int the fourth column).

Thank you!

Recommended Answers

All 2 Replies

Thank you for your reply, but I haven't found the stuff there I was looking for. However, I've figured it out, so I post it to the others:

Control tex1 = GridView1.Rows[RowID].Cells[8].Controls[1];
//Here's the controlsource
TextBox box;
box = (TextBox)(tex1.FindControl("Name of the control"));

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.