469,887 Members | 1,445 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,887 developers. It's quick & easy.

Datagrid problem

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 eventHandler..it'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
0 2594

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Chris Plowman | last post: by
reply views Thread by Emerson | last post: by
5 posts views Thread by Jeff | last post: by
4 posts views Thread by The Alchemist | last post: by
9 posts views Thread by tshad | last post: by
4 posts views Thread by tshad | last post: by
9 posts views Thread by rn5a | last post: by
2 posts views Thread by =?Utf-8?B?Y3JlYXZlczA2MjI=?= | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.