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

Getting a value from checked Datagrid cell

Hello,
I have got a datagrid with first column as a checkbox. I'm trying to
retrieve values from rows with checkbox checked.
For one column I'm doing something like:

<asp:datagrid id="Grid1" runat="server" DataKeyField="serial"
AutoGenerateColumns="True">
<ItemStyle></ItemStyle>
<HeaderStyle></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="First">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:CheckBox ID="chkSelection" Runat="server" Checked="true"
AutoPostBack="true"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>

That's the code behind:

Private Sub btnGenerate_Click(ByVal sender As System.Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles btnGenerate.Click
Dim arrSerial As New ArrayList
Dim dgi As DataGridItem

For Each dgi In Grid1.Items
Dim chkbox As CheckBox
chkbox = CType(dgi.FindControl("chkSelection"), CheckBox)
If chkbox.Checked Then
Grid1.Data()
arrSerial.Add(Grid1.DataKeys(dgi.ItemIndex).ToStri ng())
End If
Next
End Sub

The above code works perfectly for the column serial (DataKeyField =
"serial"), what should I do to get checked values from other column?
Any help would be appreciated

Jan 12 '06 #1
0 1085

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

Similar topics

2
by: Graham Y | last post by:
I have a datagrid, populated via a SQL dataset, and I want the user to select a row by clicking on it and then using the value in the first cell as my key for my next query. Using...
1
by: Blake Versiga | last post by:
When editing a datagrid (C#) I need to know if the user changed the value of cell AND what the previous value was. Is this possible? If so how do I get the previous value or at least if the...
2
by: Colin McGuigan | last post by:
This is a translation of an ASP page to ASP.Net. First, the background: The goal is to have a grid of different settings for the application -- think something along the lines of the Property...
5
by: Jason | last post by:
I've been trying to figure out a good way to do this but haven't had much luck, any input would be greatly appreciated. Basically, after a datagrid is sorted, how can I get the primary key value...
4
by: Jim Bancroft | last post by:
Hi everyone, I'm using a DataGrid with TemplateColumns. My DataGrid is located in a cell of an asp:Table. I did this so it's positioned correctly onscreen. One of the DataGrid's...
2
by: niceguy | last post by:
Hi I was wondering if its possible to get the exact displayed text from a cell in a datagrid. I need to get the displayed text and not any 'real' database value or anything that the cell...
4
by: gugu | last post by:
Hi I have a datagrid which has 20 rows and 20 columns, 15 of 20 columns are checkboxs and their headertexts, datafields are dynamic. I need to loop through the whole page to see if the specific...
0
by: alan | last post by:
Hello, I have got a datagrid with first column as a checkbox. I'm trying to retrieve values from rows with checkbox checked. For one column I'm doing something like: <asp:datagrid id="Grid1"...
1
by: mkrei | last post by:
I have datagrid that I format at runtime with tablestyles and adding columns. I have a DataGridBoolColumn that I have subclassed, but can't get the right result. I want to disable a cell based on...
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: 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:
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.