the following gridview aspx
Expand|Select|Wrap|Line Numbers
- <Columns>
- <asp:CheckBoxField HeaderText="Select"
- DataField="prjused">
- <ControlStyle Width="50%" />
- <ItemStyle Width="50%" />
- </asp:CheckBoxField>
- <asp:TemplateField HeaderText="BOINC Project">
- <ItemTemplate>
- <asp:Label ID="lbProject" runat="server"
- Text='<%# Bind("prjname") %>'></asp:Label>
- </ItemTemplate>
- <ItemStyle Width="50%" />
- </asp:TemplateField>
- </Columns>
the following C# code created and bound the gridview
Expand|Select|Wrap|Line Numbers
- private DataSet FormPNdataset()
- {
- DataSet dsTemp = new DataSet();
- DataTable Tables = new DataTable();
- dsTemp.Tables.Add(Tables);
- dsTemp.Tables[0].Columns.Add("prjused", System.Type.GetType("System.Boolean"));
- dsTemp.Tables[0].Columns.Add("prjname",System.Type.GetType("System.String"));
- foreach (string strname in ProjectNames)
- {
- DataRow dr = dsTemp.Tables[0].NewRow();
- dr["prjused"] = true;
- dr["prjname"] = strname;
- dsTemp.Tables[0].Rows.Add(dr);
- }
- return dsTemp;
- }
- ---then--
- gv.DataSource = FormPNdataset();
- gv.DataBind();
Googleing I see where someone suggested using "BindingLIst" and I found this reference: http://msdn.microsoft.com/en-us/library/ms132679.aspx but this seems only for listboxes and not gridviews.
I can always add an unbound column of checkboxes and do my own checkbox state control but I would rather use a two way data set.
maybe there is an asp.net version of the windows forms widget "CheckListBox" ? I am trying to roll my own CheckListBox.
thanks for looking