By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,508 Members | 1,856 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,508 IT Pros & Developers. It's quick & easy.

Datagrid problem

P: n/a
I have a dataview and binding to a datagrid. On
ItemBound I'm adding a checkbox dynamically for each
rows. It works ok but my problem is on checkedChanged i
have addded a's not getting fire at all
In aspx file. Somebody, suggested me to add
<%# chk_Click()%> in my aspx file but it didn't work..Any
help in this regard is appreciated.

Raj Anand

ascx.cs file
<asp:datagrid id="DataGrid1" style="Z-INDEX: 103; LEFT:
160px; POSITION: absolute; TOP: 128px" runat="server"
Width="345px" CellPadding="1" BorderColor="Tan"
ForeColor="Black" BackColor="Gainsboro" BorderWidth="1px"
AutoGenerateColumns="False" OnItemDataBound="ItemBound"

<SelectedItemStyle ForeColor="GhostWhite"
temStyle BackColor="White"></AlternatingItemStyle>
<HeaderStyle Font-Bold="True"
<FooterStyle BackColor="Tan"></FooterStyle>
<asp:BoundColumn DataField="PolicyName" HeaderText="Policy
<asp:BoundColumn DataField="PolicyNumber"
HeaderText="Policy Number"></asp:BoundColumn>
<PagerStyle HorizontalAlign="Center"
Code aspx.cs
public void ItemBound(object sender,

{if ((e.Item.ItemType == ListItemType.Item) ||
(e.Item.ItemType == ListItemType.AlternatingItem))
DataRowView drv = (DataRowView) e.Item.DataItem;
string PolicyName = drv["PolicyName"].ToString();
System.Web.UI.WebControls.CheckBox chk = new CheckBox
(chk.Text = PolicyName;
chk.AutoPostBack = true;
chk.ID = e.Item.ItemIndex.ToString();
//Add event handler
this.chk.CheckedChanged += new System.EventHandler


private void chk_Click(object sender, System.EventArgs e)

// Do something

Nov 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.