DataGrid + CheckBox + OnCheckedChange problem

M

Marcin

i wrote following asp code

<%@ Page language="c#" Codebehind="ListaUczniow.aspx.cs"
AutoEventWireup="false" Inherits="SzkolnyMedyk.ListaUczniow" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm2</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<div align="center">
<form id="ListaUczniow" method="post" runat="server">
<asp:datagrid id="dataGrid" runat="server" Width="557px"
AllowSorting="True" AllowCustomPaging="True"
AllowPaging="True">
<SelectedItemStyle ForeColor="#FFFFC0"
BackColor="#FFFF80"></SelectedItemStyle>
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:CheckBox ID="selectedItem" Runat="server"
OnCheckedChanged="dataGrid_checkedChanged"
AutoPostBack="True"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid></form>
</div>
</body>
</HTML>


(un)checking checkbox selectedItem should fire
dataGrid_checkedChanged, but it never does...
Any idea why???
i appreciate any suggestions.
 
M

Mohamed El Ashmawy

Hello,
It should function correctly.
How do you implement dataGrid_checkedChanged?
I've used: Public Sub dataGrid_checkedChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs)
as the header

Please check what do you do in form load. Don't rebind the grid at postback.
Use !Page.IsPostback to check that this is a new form then bind. Does it
work if you do so?

Regards
Mohamed El Ashmawy
MEA Developer Support Center
ITWorx on behalf of Microsoft EMEA GTSC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,173
Latest member
GeraldReund
Top