Hi! can anyone tell me what wrong with following c# code. I am getting an error like - CS0117: 'object' does not contain a definition for 'Add'
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Object mycountries = new Hashtable();
mycountries.Add("N", "Norway");
mycountries.Add("S", "Sweden");
mycountries.Add("F", "France");
mycountries.Add("I", "Italy");
rb.DataSource = mycountries;
rb.DataValueField = "Key";
rb.DataTextField = "Value";
rb.DataBind();
}
}
PalPosted Jul 23, 2008, 10:23 AM
Niradhip ChakrabortyPosted Jul 23, 2008, 10:11 AM
Check first which radio button is selected by the user and then use "rb.text"
Note: t should be in caps for 'text'. It is 'Text'
PalPosted Jul 23, 2008, 9:56 AM
Hi ! Niradhip
Thanks for your reply. That works fine but i am getting one more error for displayng the text. errros is : CS0117: 'System.Web.UI.WebControls.Label' does not contain a definition for 'text'
void displayMessage(object s, EventArgs e)
{
lbl1.text = "Your favorite country is: " + rb.SelectedItem.text;
}
Thanks
Niradhip ChakrabortyPosted Jul 23, 2008, 9:23 AM
Please define the hash table in following way.
Hashtable hstdate = new Hashtable();
hstdate.Add(key,value);