Re: building dynamic list of web from controls

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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.)







.



Relevant Pages

  • Sql2000 storing and retrieve checkbox value..
    ... I am able to store the value of the checkbox and retrieve when i want to ... Now sql 2000 store value as True and False for checked and notchecked... ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Sql2000 storing and retrieve checkbox value..
    ... I am able to store the value of the checkbox and retrieve when i want to ... Now sql 2000 store value as True and False for checked and notchecked... ... And i use this string to insert value of checkbox into database. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Sql2000 storing and retrieve checkbox value..
    ... I am able to store the value of the checkbox and retrieve when i want to edit.. ... And when i retrieve i need to see my checkbox ticked if it got value y and not ticked if it got value n in sql 2000 database. ... And i use this string to insert value of checkbox into database. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Vb.net 2008 Datagridview bound/unbound columns update datasour
    ... If you do not need to store the column information - no need to: ... Dim source As DataTable = getDataFromSqlServer ... but I suspect that because the grid checkbox column is ... datarow) then the unbound columns if checkbox values are selected i.e. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Way to retrieve a count of objects?
    ... you didn't misunderstand what I'm trying to achieve. ... Is there a way to retrieve a count via WMI using ... > Hi Matt, ...
    (microsoft.public.win32.programmer.wmi)