CheckBox Click Event in DataGrid

krasimir

Newcomer
Joined
Feb 19, 2004
Messages
5
web,Asp.net,Vb.net,VS.net

Good day ,

I have DataGrid and CheckBox Control placed in Template Column

I like to capture Check Box On Click Event.
I can capture Click Event in DataGrid ItemCommand with Button Control but I could not manage with the CheckBox Control.

Any Help?
Thank you
Krasimir
 
Hi
I'm wondering why i can not give a CommandName to the CheckBox

--
CheckBox AutoPostBack = true
also DataGrid EnableViewState = False

when I place Button Control in Template Control with Command Name = OnClick I get the result in Label1.

I would like to get the result too when I click CheckBox Control.

This is the code which I place for the Button
Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.ItemCommand

If (e.CommandName = "OnCLick") Then
Label1.Text = "Clicked"
End If

EndSub
 
HI,
when i type in htm OnCheckedChanged="click" after that when i build comes

Compiler Error Message: BC30456: 'click' is not a member of WebForm1.aspx
 
HI,
Yes I did // with

Public Sub Click(ByVal sender As Object, ByVal e As System.EventArgs)
Label3.Text = "Clicked"

End Sub

but can not use this sub "Click" in DataGrid ItemCommand
 
I am not sure why you are capturing the Checked in the ItemCommand sub, in your TemplateColumn, you should have

<asp:CheckBox ID="chkCheck" Runat=server OnCheckedChanged="checked_changed" AutoPostBack=True></asp:CheckBox>

Then have a Public Sub checked_changed , remember to rebind the datagrid on postback, this will work for you.
 
I would like to use DataGrid ItemCommand in order to insert the row in db table.

when i click the check box sqlcommand to fire the row insert statement.

i read about idea to add hidden input field in check box but seems to be too complicated

now i'm trying to use datagrid e.item.Findcontrol in checked_changed sub
 
Back
Top