With a GridView
control in .NET is there any way to change the Select
option in a GridView
to a Checkbox
, how do you select multiple rows?
I tried adding a CheckBoxField
into my GridView
but when I ran it it didn't show up.
With a GridView
control in .NET is there any way to change the Select
option in a GridView
to a Checkbox
, how do you select multiple rows?
I tried adding a CheckBoxField
into my GridView
but when I ran it it didn't show up.
Adding checkbox to Gridview is as simple as adding TemplateField of any control.
I tried adding a CheckBoxField into my gridview but when I ran it it didn't show up.
There should be other columns binding data to the grid. Also, check visible property of checkbox.
Refer to this link for more on this. link text
I always just add a column to the DataTable that I am binding to.
dt.Columns.Add(new DataColumn("Include", typeof(Boolean)));
Or in my SQL I will have:
declare @include bit
set @include = 0
select
@include Include,
....
More can be found on my blog here
I did work it out in the end, thanks to ExpertSoul for the headsup on the tutorial. This was all I needed in the markup and it worked great:
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="PublicationSelector" runat="server" />
</ItemTemplate>
</asp:TemplateField>
The other thing that the tutorial had which was great was an onclick event so that you could pick up the id # when the submit button was clicked, which was the next bit...
Great stuff.