Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
news.microsoft.com #1
Capture CheckBox Click Event
I have a datagrid with a checkbox column. The column is bound to adatabase,
and I have no problem capturing a click event on the checkbox using the
OnCheckChanged event handler.
Here is a sample of the html used to build the column:
<asp:TemplateColumn HeaderText="Crew Chief?">
<HeaderStyle HorizontalAlign="Center" Width="40px"
VerticalAlign="Middle"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:checkbox id=chkChief runat="server"
cssclass="FormFieldText2"
OnCheckedChanged="cbChief_Clicked"
COMMANDARGUMENT='<%#Container.DataItem("SAN") %>'
AutoPostBack=True Checked='<%#
bSetCheckValue(Container.DataItem("IsChief"))%>'>
</asp:checkbox>
</ItemTemplate>
</asp:TemplateColumn>
The event handler function fires and I get a reference to the checkbox
object that was clicked.
The problem is that I am trying to get a reference to the row that the
checkbox was clicked in to retrieve the datakey value. I know I could loop
through the entire dataitem list and find the match, but what I was trying
to do was pass the datakey value for the row as a command arguement, so that
I can use the datakey value directly in the event handler.
Has anyone been able to make this work?
Thanks,
Marc.
news.microsoft.com Guest
-
double click causes click-event anddoubleClick-event
I too am interested in a response to this. I see all kinds of information on how to enable the double-click event, but not how to distinguish... -
stumped...table - row - click event, cancel checkbox event
I have a html table and mutliple rows. On each row i put an onclick event that opesn a modal window and prompts the user for some information. I... -
how to use click event on a checkbox in cfgrid
I am using checkboxes in a cfgrid by putting type="boolean" in my cfgridcolumn tag The problem is, I need a click event to be fired when any of the... -
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl.
Hello I have the following situation: (everything is dynamic (controls.add)) 1. Button.Init { WasButtonClickFired = true } 2.... -
How Do I : Add a Click event to a checkbox in a DataGrid
Hello, I need to know when a user clicks a checkbox, in a datagrid, so I can then update the database. I.E. I need to know which row has been... -
Marc Rivait #2
Re: Capture CheckBox Click Event
Here is the answer to my post. Thanks to Michael.
protected void cbChief_Clicked(object sender, EventArgs e) {
string _val = ((CheckBox)sender).Attributes["COMMANDARGUMENT"]; // Here we
received value in the attribute of checkbox.
foreach(DatagridItem dr in Datagring.Items)
{
// your code.
}
}
The Best Regards,
Net Developer
Michael Tkachev
"news.microsoft.com" <nospam@rivaitsoftware.com> wrote in message
news:OiFXtAYwDHA.1908@TK2MSFTNGP10.phx.gbl...adatabase,> I have a datagrid with a checkbox column. The column is bound toloop> and I have no problem capturing a click event on the checkbox using the
> OnCheckChanged event handler.
>
> Here is a sample of the html used to build the column:
> <asp:TemplateColumn HeaderText="Crew Chief?">
> <HeaderStyle HorizontalAlign="Center" Width="40px"
> VerticalAlign="Middle"></HeaderStyle>
> <ItemStyle HorizontalAlign="Center"></ItemStyle>
> <ItemTemplate>
> <asp:checkbox id=chkChief runat="server"
> cssclass="FormFieldText2"
> OnCheckedChanged="cbChief_Clicked"
> COMMANDARGUMENT='<%#Container.DataItem("SAN") %>'
> AutoPostBack=True Checked='<%#
> bSetCheckValue(Container.DataItem("IsChief"))%>'>
> </asp:checkbox>
> </ItemTemplate>
> </asp:TemplateColumn>
>
> The event handler function fires and I get a reference to the checkbox
> object that was clicked.
>
> The problem is that I am trying to get a reference to the row that the
> checkbox was clicked in to retrieve the datakey value. I know I couldthat> through the entire dataitem list and find the match, but what I was trying
> to do was pass the datakey value for the row as a command arguement, so> I can use the datakey value directly in the event handler.
>
> Has anyone been able to make this work?
>
> Thanks,
> Marc.
>
>
Marc Rivait Guest



Reply With Quote

