How to access selected row values in Datalist

G

Gary Frank

I added a couple of labels and a button to a Datalist control called
"dlSignIn" by adding them to the Item template. The labels are bound to a
dataset column. Program code gets executed in the
dlSignIn_SelectedIndexChanged subroutine when I click the button in the
datalist. And the dlSignIn.SelectedIndex property has the correct index for
the Datalist row that was selected. Now I would like to access the values
in the labels of that row. I think I could do it indirectly by reading the
values in the corresponding row of the dataset which is the datasource. But
is there a way to directly access the values from the controls within the
Datalist control?
 
G

Guest

If you want to get the value of a text box which is placed in a datalist
((TextBox)DataList1.Items[DataList1.SelectedIndex].FindControl("TextBox1")).Text

If you want to get the value of a label which is placed in a datalist,
((Label)DataList1.Items[DataList1.SelectedIndex].FindControl("Label1")).Text

Same way for other controls also...

Hope this code written in C# will help you...

Sai Kiran,
Cybersoft.
 

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,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top