Question : Jquery and C#

Hi Experts,
I have a Radiobuttonlist and i need the most recent one added which added to list get checked during page load.
 


<asp:ImageButton ID="btn_AddBld1" ImageUrl="/house.gif"
                                                                                                runat="server" CausesValidation="false" TabIndex="-10"  OnClick ="btn1click"/>

protected void btn1click(object sender, EventArgs e)
    {
        string test = string.Empty;
        test = "house";
        int rbCnt = 0;
        rbCnt = rbHouse.Items.Count;
        rbCnt++;
        test = test + rbCnt.ToString();
        rbHouse.Items.Add(new ListItem("<b>" + test + "</b>", test,true));
       
       
    }
Kind Regards,
Pooja

Answer : Jquery and C#

Why do you want make it with jQuery? The last boolean value in ListItem constructor is for "Enabled" property , not for the Selected property, so make it this way:

1:
2:
3:
4:
5:
6:
7:
8:
9:
void btn1click(object sender, EventArgs e)
{
string itemName = "house" + (rbHouse.Items.Count + 1);

ListItem newListItem = new ListItem(string.Format("<b>{0}</b>", itemName), itemName, true);
newListItem.Selected = true;

rbHouse.Items.Add(newListItem);
}
Random Solutions  
 
programming4us programming4us