This is a migrated thread and some comments may be shown as answers.

Not able to set value in rad numeric text box

3 Answers 305 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Esther Nirmala
Top achievements
Rank 1
Esther Nirmala asked on 03 Aug 2011, 06:05 AM

Hi,

    I am using Rad numeric text box in my page. Am trying to set the value of numeric text box on seleting a drop down list. But its not displaying the data. And i tried to set the value in prerender of text box also.. that is also not working . How to set the value of rad numeric text box in code behind. If i assign directly to value property its working.. If am assigning from viewstate its not working.

Here is the code i tried:

protected void dropDownListResource_SelectedIndexChanged(object sender, EventArgs e)
        {
double DailyRateToUse = val; //val - viewstate variable
 radNumericTextboxRate.Value = Convert.ToDouble(DailyRateToUse);
        }
    protected void radNumericTextboxRate_PreRender(object sender, EventArgs e)
        {
double DailyRateToUse = val//val - viewstate variabledouble
radNumericTextboxRate.Value = Convert.ToDouble(DailyRateToUse);
  
}

Thanks
Esther

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 03 Aug 2011, 06:57 AM
Hello Esther,

I tried the same scenario and it worked as expected on my end. Here is the sample code that I tried to access RadNumericTextBox in SelectedIndexChanged event of the DropDownList.

C#:
protected void drop_SelectedIndexChanged1(object sender, EventArgs e)
{
        DropDownList list = sender as DropDownList;
        GridDataItem item = (GridDataItem )list.NamingContainer;
        RadNumericTextBox txt = (RadNumericTextBox)item.FindControl("RadNumericTextBox1");
        double DailyRateToUse = 123;
        txt.Value = Convert.ToDouble(DailyRateToUse);
}

Thanks,
Princy.
0
Esther Nirmala
Top achievements
Rank 1
answered on 03 Aug 2011, 07:21 AM
hi princy.. If am directly assigning its working.. If am assigning the value from viewstate, its not working.. Pls help me in achieving this req.

Thx
Esther.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 03 Aug 2011, 10:37 AM
Hello,

RadNumericTextBox txt = (RadNumericTextBox)item.FindControl("RadNumericTextBox1");
if(!string.IsNullorEmpty(ViewState["Test"]))
{
try
{
    txt.Text = Convert.ToDouble(ViewState["Test"].ToString());
}
Catch
{
 // invalid Text in View State
}
else
{
 txt.Text = Convert.ToDouble("0");
}

}



Thanks,
Jayesh Goyani
Tags
General Discussions
Asked by
Esther Nirmala
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Esther Nirmala
Top achievements
Rank 1
Jayesh Goyani
Top achievements
Rank 2
Share this question
or