473,378 Members | 1,496 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Selecting specific data to download

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

Nov 16 '05 #1
5 1525
Hi Dave,

Both Windows Forms and ASP.NET have DataGrids and CheckBoxes and each
technology would implement this differently. Perhaps posting to the
appropriate news group for the technology your using will get you the best
answer.

Joe
--
http://www.csharp-station.com

"Dave" <da***@revilloc.remove.this.bit.com> wrote in message
news:1c****************************@phx.gbl...
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

Nov 16 '05 #2
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]
- mv*@spam.guard.caspershouse.com
"Dave" <da***@revilloc.remove.this.bit.com> wrote in message
news:1c****************************@phx.gbl...
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

Nov 16 '05 #3
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 datasource, which would be of type boolean. This way, you can check off theitems in the data source that you want to process.

Then, when you click your button, just process the rows where thatcolumn value is true. You can easily apply a filter to a DataTable using aDataView class (and then just cycle through what the DataView returns toyou).

I don't believe the current DataGrid supports multiple row selection (orat least, I haven't been able to figure out how to get it programatically).
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Dave" <da***@revilloc.remove.this.bit.com> wrote in messagenews:1c****************************@phx.gbl...
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

.

Nov 16 '05 #4
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]
- mv*@spam.guard.caspershouse.com

"Dave" <da***@revilloc.remove.this.bit.com> wrote in message
news:1d****************************@phx.gbl...
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]
- mv*@spam.guard.caspershouse.com
"Dave" <da***@revilloc.remove.this.bit.com> wrote in

message
news:1c****************************@phx.gbl...
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

.

Nov 16 '05 #5
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:DataGrid 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:DataGrid>

<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">&nbsp;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 thecolumn in the data source, and you can check it when the button is pressed.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Dave" <da***@revilloc.remove.this.bit.com> wrote in messagenews:1d****************************@phx.gbl...
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]
- mv*@spam.guard.caspershouse.com
"Dave" <da***@revilloc.remove.this.bit.com> wrote in

message
news:1c****************************@phx.gbl.. .
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

.

.

Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Michel | last post by:
Hi, I like to build a small simple dinamic website: Point-of-sale (detail-shop), So entering stock, logging all sales, print out invoices and download the logs to be imported into Excel. I...
4
by: webhigh | last post by:
Iım not sure if this a PHP question or an MySQL question but here it goes. I have a repeat region of a table called userid What Iım trying to accomplish is being able to edit the record and...
3
by: Simon G Best | last post by:
Hello! The C++ standard library provides facilities for finding out the sizes (and other such stuff) of numeric types (::std::numeric_limits<>, for example). What I would like to do is to...
19
by: Ben Gribaudo | last post by:
Hello! I am trying to query a MySQL table and retrieve either the earliest or the latest message in each thread. The messages are in a table with MsgID being the primary key and fThreadID...
12
by: Lawrence Oluyede | last post by:
I've some problems with filtering out a specific element by the following xml snippet (is part of a bigger xml document): <entry> <link...
4
by: Sami | last post by:
I hope someone will tell me how to do this without having to do any VB as I know nothing in that area. I am a rank beginner in using Access. I have created a database consisting of student...
3
by: joshsackett | last post by:
I am having a problem with indexes on specific tables. For some reason a query that runs against a view is not selecting the correct index on a table. I run the same query against the table...
5
by: Mahesh S | last post by:
Hi I would like to write a SQL select statement that would fetch rows numbered 50 to 100. Let me clarify, if i say "fetch first 10 rows only", it returns the first 10 rows from the resultset....
0
by: jaredciagar | last post by:
Hi Guys, Can You Help Me PLease, I'm Currently facing Problems in my system... I need some help... I'm using VB script,ASP.net,MS SQL Server2005 I want to select a specific data in...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.