RadioButtonList in DataList EditItemTemplate

Discussion in 'ASP .Net' started by Sudheer Aalla, Sep 20, 2006.

  1. Hi,

    When I try to reference the radiobuttonlist control in edititemtemplate in
    ItemDataBound event of datalist control I am getting NULL reference. I am
    trying to pre select the yes/no button depending on the label text in item
    template. But I am able to get the value of lable control which is in
    itemtemplate. Is there anything else I am missing here???

    public void DataListItems_ItemDataBound(object sender, DataListItemEventArgs
    e)

    {

    if (DataListItems.EditItemIndex != -1 && e.Item.ItemIndex != -1 &&
    e.Item.HasControls())

    {

    Label rbllblIsAdded = (Label)e.Item.FindControl("lblIsAdded");

    RadioButtonList rbl =
    (RadioButtonList)e.Item.FindControl("edtrblIsAdded");

    if (rbllblIsAdded.Text == "Added")

    {

    rbl.SelectedValue = "Yes";

    }

    else

    {

    rbl.SelectedValue = "No";

    }

    }

    }



    <EditItemTemplate>

    <table width="100%" cellspacing="0" cellpadding="0" style="height:100%;">

    <tr>

    <td width="10%">

    <asp:RadioButtonList ID="edtrblIsAdded" RepeatDirection="Horizontal"
    runat="server">

    <asp:ListItem Value="Yes">A</asp:ListItem>

    <asp:ListItem Value="No">R</asp:ListItem>

    </asp:RadioButtonList>

    <asp:RequiredFieldValidator ID="RFVedtrblIsAdded" runat="server"
    ErrorMessage="Please select added/removed"

    ControlToValidate="edtrblIsAdded" ValidationGroup="UpdateValidationControls"
    ToolTip="Please select added/removed">*</asp:RequiredFieldValidator>


    </td>

    ........



    Thanks,

    Sudheer.
     
    Sudheer Aalla, Sep 20, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SStory

    Datalist EditItemTemplate

    SStory, Aug 19, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    500
    SStory
    Aug 19, 2003
  2. Nevyn Twyll
    Replies:
    8
    Views:
    1,882
  3. Stuart Shay
    Replies:
    0
    Views:
    408
    Stuart Shay
    Dec 26, 2004
  4. Luis Esteban Valencia
    Replies:
    1
    Views:
    493
    John Saunders
    Jan 6, 2005
  5. Replies:
    1
    Views:
    1,788
    Grant Merwitz
    Sep 27, 2005
Loading...

Share This Page