Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

Getting values from another control in a datalist

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Regan - 10 Mar 2008 00:09 GMT
So, I have DatalistA on my form; it is rebinding with a refreshed datasetB
after each post back.

DatalistA contains buttonC and labelD, bound to datasetB.

What do I have to do in the OnClick event of buttonC, to retrieve the text
value of labelD?

Thank for your help!
Eliyahu Goldin - 10 Mar 2008 10:36 GMT
Instead of handling OnClick event for the button, handle ItemCommand event
for the datalist:<asp:DataList
OnItemCommand="Item_Command"><ItemTemplate><asp:Button CommandName="XXX"
/></ItemTemplate></asp:DataList>

and in the code behind:
void Item_Command(Object sender, DataListCommandEventArgs e)
{
       if (e.CommandName == "XXX")
           string label = (e.Item.FindControl("labelD") as Label).Text;
}

Signature

Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net

> So, I have DatalistA on my form; it is rebinding with a refreshed datasetB
> after each post back.
[quoted text clipped - 5 lines]
>
> Thank for your help!
Regan - 12 Mar 2008 02:54 GMT
Thanks Eliyahu =)

I appreciate the help. I will explore this soon.

> Instead of handling OnClick event for the button, handle ItemCommand event
> for the datalist:<asp:DataList
[quoted text clipped - 17 lines]
>>
>> Thank for your help!

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.