dg event not firing.

G

Guest

hello, this is my front end script

<begin>
<asp:DataGrid id="dgAnn" runat="server" Width="100%"
AutoGenerateColumns="False" datakeyfield="Anncement_Id"
OnSelectedIndexChanged="getSelected">
</end>

.... notice i have a onselectedindexchange and in my code behind i have a
getSelected <below> wheni click on

<begin>
<asp:TemplateColumn HeaderText="Title" HeaderStyle-CssClass="row_hdr">
<ItemTemplate>
<asp:LinkButton ID="lnkAnn" Runat="server" text='<%#
DataBinder.Eval(Container.DataItem, "title") %>'/>
</ItemTemplate>
</asp:TemplateColumn>
<end>
it wont freaking fire. why?

protected void getSelected(Object src, EventArgs e)
{
string id = dgAnn.DataKeyField[dgAnn.SelectedIndex].ToString();
Response.Write(id);
}
 
G

Guest

Hi,

Have you added it to the event i.e., DataGrid.OnSelectedIndexChanged +=
<your event name> in the code behind file?

Prakash.C
 
G

Guest

yes i have, butits still not firing... why?

Prakash.NET said:
Hi,

Have you added it to the event i.e., DataGrid.OnSelectedIndexChanged +=
<your event name> in the code behind file?

Prakash.C

Asha said:
hello, this is my front end script

<begin>
<asp:DataGrid id="dgAnn" runat="server" Width="100%"
AutoGenerateColumns="False" datakeyfield="Anncement_Id"
OnSelectedIndexChanged="getSelected">
</end>

... notice i have a onselectedindexchange and in my code behind i have a
getSelected <below> wheni click on

<begin>
<asp:TemplateColumn HeaderText="Title" HeaderStyle-CssClass="row_hdr">
<ItemTemplate>
<asp:LinkButton ID="lnkAnn" Runat="server" text='<%#
DataBinder.Eval(Container.DataItem, "title") %>'/>
</ItemTemplate>
</asp:TemplateColumn>
<end>
it wont freaking fire. why?

protected void getSelected(Object src, EventArgs e)
{
string id = dgAnn.DataKeyField[dgAnn.SelectedIndex].ToString();
Response.Write(id);
}
 
G

Guest

Hi Asha,

You are defining a link button:

<asp:LinkButton ID="lnkAnn" Runat="server" text='<%#
DataBinder.Eval(Container.DataItem, "title") %>'/>

but this link button does not contain the CommandName property and so the
SelectedIndexChanged event is not fired.

add the CommandName property and set its value to "select". Hope everything
will work fine then.

Cheers,
Rahul Anand
 

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,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top