Hi Nicholas.
Thanks for your help so far. I am slowly getting closer,
but not quite there yet.
What I am not sure about is how to retrieve the checked
lines to use as a filter...
Code snippetts below.
*****************************************************
private void GetSchoolsData(string SchoolType, string
SchoolLocation, string SchoolRange)
{
try
{
conn.Open();
SqlCommand cmd =
conn.CreateCommand();
cmd.CommandText = "Select
0 as TickColumn, SchoolID, [School Name], Address1,
Headteacher from SchoolsData where [School Name] between
@NameStart and @NameEnd and Area like @Area order by
[School Name]";
// All parameters defined here...
SqlDataAdapter SqlDA =
new SqlDataAdapter();
SqlDA.SelectCommand = cmd;
DataSet SchoolData = new
DataSet();
SqlDA.Fill
(SchoolData, "SchoolsList");
SchoolsListGrid.DataSource = SchoolData.Tables
["SchoolsList"];
SchoolsListGrid.DataBind
();
}
finally
{
conn.Close();
}
}
private void LinkButton2_Click(object
sender, System.EventArgs e)
{
Response.Write("Clicked here");
}
****************************************************
<asp

ataGrid id="SchoolsListGrid" runat="server"
Font-Names="Arial" Font-Size="X-Small"
AutoGenerateColumns="False"
CellPadding="4" BackColor="White"
BorderWidth="1px" BorderStyle="None" BorderColor="#3366CC"
Width="100%">
<SelectedItemStyle Font-Bold="True"
ForeColor="#CCFF99"
BackColor="#009999"></SelectedItemStyle>
<ItemStyle ForeColor="#003399"
VerticalAlign="Top" BackColor="White"></ItemStyle>
<HeaderStyle Font-Bold="True"
ForeColor="#CCCCFF" BackColor="#003399"></HeaderStyle>
<FooterStyle ForeColor="#003399"
BackColor="#99CCCC"></FooterStyle>
<Columns>
<asp:TemplateColumn
HeaderText="X">
<ItemTemplate>
<asp:CheckBox
id=CheckBox2 runat="server" Checked='<%# Convert.ToBoolean
(DataBinder.Eval(Container.DataItem, "TickColumn")) %>'>
</asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn
HeaderText="School Name">
<ItemTemplate>
<asp:LinkButton
id=LinkButton1 OnCommand="SchoolsLink_Click"
CommandArgument='<%#DataBinder.Eval
(Container.DataItem, "School Name")%>'
CommandName="SchoolLink_Click" Runat="server">
<%
#DataBinder.Eval(Container.DataItem, "School Name")%>
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn
HeaderText="Address">
<ItemTemplate>
<%#DataBinder.Eval
(Container.DataItem, "Address1")%>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn
HeaderText="Head Teacher">
<ItemTemplate>
<%#DataBinder.Eval
(Container.DataItem, "Headteacher")%>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle HorizontalAlign="Left"
ForeColor="#003399" BackColor="#99CCCC"
Mode="NumericPages"></PagerStyle>
</asp

ataGrid>
<asp:LinkButton id="LinkButton2" runat="server"
Font-Names="Arial" Font-Size="X-Small" ToolTip="Click to
download the selected schools">Click here</asp:LinkButton>
<FONT face="Arial" size="2"> to download
selected schools</FONT>
******************************************************
The idea is to tick the boxes, then click the LinkButton
to download. Currently, I have just got a response.write
in the linkbutton event, but here will be where I should
manage the selected list.
I am probably looking at this from the wrong direction. I
couldn't see how to bind the column when I had a checkbox
in it.
Any sample code that can set me straight would be
appreciated.
Best regards,
Dave Colliver.
http://www.BlackpoolFOCUS.com
-----Original Message-----
Dave,
I would recommend adding the boolean column to the data source itself,
and then bind to that in the grid. Then, bind the checkbox column to the
column in the data source, and you can check it when the button is pressed.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
Hi Nicholas,
I am using ASP.NET (with C#)
Thanks for your reply. I have done a bit more research on
the net and not found anything.
I have added a checkbox column in my datagrid. The
columns are not automatically generated.
I have a link button at the bottom of the page,
marked "Click here to download". In the linkbutton event,
I just do a response.write to show that the event has
been reached.
How can I tell what check boxes are ticked?
Thanks.
Best regards,
Dave Colliver.
http://www.SwindonFOCUS.com
-----Original Message-----
Dave,
In order to do this, you would have to add another column to your data
source, which would be of type boolean. This way, you can check off the
items in the data source that you want to process.
Then, when you click your button, just process the rows where that
column value is true. You can easily apply a filter to a DataTable using a
DataView class (and then just cycle through what the DataView returns to
you).
I don't believe the current DataGrid supports multiple row selection (or
at least, I haven't been able to figure out how to get it programatically).
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
Hi all,
Apologies if this is the wrong group. I have done a
search on google but my keywords are probably no good.
What I want to do is to display a list of data in a
datagrid (which I have already done). At the side of the
list, I want to put in a checkbox, basically to select
that line.
At the bottom, I want a button that will know what lines
I have selected, and I can then continue with what the
button is to do (namely, to generate a CSV file of the
selected data).
Is there an easy way to do this?
I am still fairly new to C# so step by step would be
appreciated. (I am not asking for the job to be done,
just some guidance.)
Thanks in advance for your help.
Best regards,
Dave Colliver.
http://www.SheffieldFOCUS.com
.
.