Do I need to use a template column in this case?

  • Thread starter Thread starter William Gower
  • Start date Start date
W

William Gower

I need to develop a datagrid that uses columns from a table. In addition I
need two columns (checkboxes) that the user will use to indicate that this
record can be closed later. The checkboxed column is not a field in the
table. It is just for the purposes of the Datagrid and I do not need to
store whether it was checked or not. Do I use a Template Column for this?
 
Hi
To answer your first question, if your going to use a checkbox column in your datagrid, there is no other way than a template column, without getting real low level and dynamically adding a column to the allready substantiated grid
I have a question though
If you are not going to store the checkbox checked value how will it be useful
The datagrid relies on state and all will be well and good as long as the user does not close the browser. Closing the browser will of course destroy the state and clear the boxes

As far as creating the template column just left click on the datagrid, add a bound column and name it, click the link at the bottom of the properties page that says convert to template column, left click on the datagrid again, select edit template and then your template column name from the context menu the mouseover produces, and drag a checkbox from the toolbox to the item section

If you dont have visual studio and your doing it by hand then your HTML code will should like thi

<asp:DataGrid id="DataGrid1" runat="server" AutoGenerateColumns="false"><Columns><asp:TemplateColumn HeaderText="MyCheckBoxColumn"><ItemTemplate><asp:CheckBox id="MyCheckBox" runat="server"></asp:CheckBox></ItemTemplate><EditTemplate><asp:TextBox id="MyTextBox" runat="server"></asp:TextBox></EditTemplate></asp:TemplateColumn></Columns></asp:DataGrid

Hope That Help
Harold
 
Back
Top