dg event not firing.

Discussion in 'ASP .Net' started by Guest, Dec 30, 2004.

  1. Guest

    Guest 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);
    }
     
    Guest, Dec 30, 2004
    #1
    1. Advertisements

  2. Guest

    Guest Guest

    Hi,

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

    Prakash.C
     
    Guest, Dec 30, 2004
    #2
    1. Advertisements

  3. Guest

    Guest Guest

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

     
    Guest, Dec 30, 2004
    #3
  4. Guest

    Guest 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
     
    Guest, Dec 30, 2004
    #4
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.