473,385 Members | 1,555 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,385 software developers and data experts.

Multiple select in a asp.net datagrid

I'm trying to create a asp.net webform with a datagrid which has been
filled with data from a database. The datagrid is filled allright but
I would like to add a checkbox at every row which the use can click to
select one or many of the rows in the datagrid once a button is
clicked. The problem is that the code behind does not recognise if the
checkbox has been check or not.

Does anyone knows how to do this?
/erik

The html code looks like this:

<asp:DataGrid id="dgListAllOrders" runat="server"
AutoGenerateColumns="False" Font-Names="Arial" CellPadding="0"
BorderWidth="1px" Font-Size="X-Small" DataKeyField="JobID">
<AlternatingItemStyle BackColor="WhiteSmoke"></AlternatingItemStyle>
<HeaderStyle Font-Bold="True" Wrap="False"
BackColor="Gainsboro"></HeaderStyle>
<Columns><asp:BoundColumn DataField="JobID" HeaderText="JobbID">
<HeaderStyle Width="50px"></HeaderStyle>
</asp:BoundColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:CheckBox id="chkJob" runat="server"
Checked="False"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>

The code behind looks like this:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim dgi As DataGridItem
Dim cb As CheckBox
Dim i As Integer = 0
Dim p As Integer

For Each dgi In dgListAllOrders.Items
cb = CType(dgi.Cells(6).Controls(1), CheckBox)
If cb.Checked Then
p = CType(dgListAllOrders.DataKeys(i), Integer)
End If
i += 1
Next

End Sub
Jul 21 '05 #1
0 3513

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

Similar topics

7
by: Billy Jacobs | last post by:
I am using a datagrid to display some data. I need to create 2 header rows for this grid with columns of varying spans. In html it would be the following. <Table> <tr> <td colspan=8>Official...
1
by: Wolffang | last post by:
From: "Wolffang" <javid@techlite.co.uk> Subject: How to do a multiple select and update in a datagrid Date: 23 October 2004 21:28 Using Visual studio.net VB I have a datagrid that brings...
5
by: Lie | last post by:
Hi all, I have problem in getting selectedindex of multiple listbox selection in a datagrid. I have a listbox with multiple selection mode inside datagrid. In Edit mode, I need to get back all...
1
by: Bob Loveshade | last post by:
I am looking for an example that shows how to select and highlight multiple rows in a DataGrid. My DataGrid is part of a Web User Control which is contained in an ASPX page. I haven't been...
1
by: Eddy Balan | last post by:
Hi. Please help me....... I would like to copy the datagrid contents to clipboard and then to paste it into Excel but I can't make a multiple selection. Eddy
8
by: Jason L James | last post by:
Hi all, does anyone know if I can create a dataview from multiple datatables. My dataset is constructed from four separate tables and then the relationships are added that link the tables...
4
by: Dave Edwards | last post by:
I understand that I can fill a datagrid with multiple queries, but I cannot figure out how to fill a dataset with the same query but run against multiple SQL servers, the query , table structure...
0
by: dbuchanan | last post by:
How do I make multiple DataGridTableStyles serve the same table? (I can get multiple styles for the same datagrid, but not multple styles for the same *table* on the same datagrid) I want to do...
0
by: rn5a | last post by:
A DataGrid control displays records from a SQL Server 2005 DB table. The AllowSorting property of the DataGrid has been set to True & the SortExpressions of the BoundColumns have been set to the...
2
by: Andy Baker | last post by:
I have a VB.NET 2003 application that uses several datagrids. The behaviour I want from the datagrid is to select (highlight) the entire row when I click on any cell in a row. I have done this...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: 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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.