473,378 Members | 1,409 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.

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 3512

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...
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
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
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.