Re: building dynamic list of web from controls
- From: v-schang@xxxxxxxxxxxxxxxxxxxx (Steven Cheng[MSFT])
- Date: Thu, 28 Apr 2005 10:57:31 GMT
Hi Scott,
Thanks for your further description. I think I did misunderstand your
question in the last response. So let me restate my understanding:
Since you bind the checkbox (or other entry field) control with datas
retrieved from database records, you want to also identify each checkbox(in
the datalist items) so as to mapping the checkbox's value with the record
in database, yes? If there're still anything I misunderstood, please feel
free to let me know.
If this is your actual requirement, I think we have the following options:
1. use the webControl.Attributes collection and store the primary key into
a certain control's attribute. For example:
=========================
private void dlFISVIEW_ItemDataBound(object sender,
System.Web.UI.WebControls.DataListItemEventArgs e)
{
DataRowView drv = e.Item.DataItem as DataRowView;
CheckBox chk = e.Item.FindControl("chkSelected") as CheckBox;
if(chk != null && drv != null)
{
chk.Attributes["id"] = drv["id"];
}
}
=======================
Then, when we retrieve the CheckBox later in postback event, we can check
its Attirubtes["id"] 's value to identify it.
2. If you don't want to use the Attributes collection. We can also consider
adding an additional HIDDEN control into the template to store the identity
of the data record, for example:
<itemTemplate>
<asp:Label id="key" runat="server" Visible="false" ..../>
<asp:CheckBox..... >
</itemtemplate>
And in ItemDataBound, we can store the primary key or other identity into
the label control's text and retrieve it later.
How do you think of this? If you have any other questions, please feel free
to post here. Thanks,
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
.
- References:
- building dynamic list of web from controls
- From: scottrm
- Re: building dynamic list of web from controls
- From: Brock Allen
- Re: building dynamic list of web from controls
- From: Steven Cheng[MSFT]
- Re: building dynamic list of web from controls
- From: scottrm
- Re: building dynamic list of web from controls
- From: Steven Cheng[MSFT]
- Re: building dynamic list of web from controls
- From: scottrm
- Re: building dynamic list of web from controls
- From: Steven Cheng[MSFT]
- Re: building dynamic list of web from controls
- From: scottrm
- Re: building dynamic list of web from controls
- From: Steven Cheng[MSFT]
- Re: building dynamic list of web from controls
- From: scottrm
- building dynamic list of web from controls
- Prev by Date: Re: treeview control in vb.net
- Next by Date: Can we set form field in Asp.net
- Previous by thread: Re: building dynamic list of web from controls
- Next by thread: hide the values in query string in ASP.net.
- Index(es):
Relevant Pages
|