Home > Archive > Visual Basic Controls > January 2006 > Getting a value from checked Datagrid cell
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
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).ToString())
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
| |
| Ken Halter 2006-01-12, 7:07 pm |
| "alan" <stan_usun@o2.pl.to> wrote in message
news:dq62q7$bl6$1@nemesis.news.tpi.pl...
>
> Private Sub btnGenerate_Click(ByVal sender As System.Object, ByVal e As
> System.Web.UI.ImageClickEventArgs) Handles btnGenerate.Click
You'll want to post that question in a .Net group. They all contain "dotnet"
or "vsnet" in their names.
This and all other groups on the MS server that start with
"microsoft.public.vb" are for VB Classic (VB versions 1-6) and were in
existance long before any .Net products were released. While some of the
code looks the same, they are very different products and require a
different set of groups.
Try one of these:
news://microsoft.public.dotnet.general
news://microsoft.public.dotnet.languages.vb
--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Freeware 4 color Gradient Frame? http://www.vbsight.com/GradFrameCTL.htm
|
|
|
|
|