is it possible to bind just the column names of a dataset to a checkboxlist. So i have ten columns in my dataset containing products sold by a company and want to populate the checkbox list with these column names so that we can track if the products are
sold by the company.
A.Venkatesan
Microsoft Certified Professional
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact venkatmca008@gmail.com
iggy985
Member
78 Points
53 Posts
Bind Column Names to checkbox list
Mar 01, 2012 01:37 PM|LINK
is it possible to bind just the column names of a dataset to a checkboxlist. So i have ten columns in my dataset containing products sold by a company and want to populate the checkbox list with these column names so that we can track if the products are sold by the company.
Thanks Ahead of time for any input
asureshkumar...
Member
301 Points
75 Posts
Re: Bind Column Names to checkbox list
Mar 01, 2012 01:43 PM|LINK
Hi..
Plz use the below code...
In Aspx page:
<asp:CheckBoxList ID="cblist" runat="Server"></asp:CheckBoxList>
In server side page:
cblist.DataSource = ds(This is dataset)
cblist.DataTextField = "COLUMN_NAME"
cblist.DataValueField = "ID"
cblist.DataBind()
A. Suresh Kumar
venkatmca008
Participant
1810 Points
341 Posts
Re: Bind Column Names to checkbox list
Mar 01, 2012 01:53 PM|LINK
Hi...try this
cmd.Connection = con cmd.CommandType = CommandType.Text cmd.CommandText = Sql dap = New SqlDataAdapter() dap.SelectCommand = cmd dap.Fill(dt) Chbox.Items.Clear() Chbox.DataSource = dt.DefaultView.ToTable(True, "name") Chbox.DataTextField = "name" Chbox.DataBind()Microsoft Certified Professional
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact venkatmca008@gmail.com
iggy985
Member
78 Points
53 Posts
Re: Bind Column Names to checkbox list
Mar 05, 2012 02:28 PM|LINK
I actually went a different route. SInce Datasets dont have columns or rows i needed to pull the DataTable and populate the checkbox using
cblClinInfo.DataSource = ds_1.Tables[0].Columns;
Thanks
all for the help