why dont u just set the Default Text of RadTextBox=0 when you creating them and then in this (prerender loop) modify them if they are not null;
How do I set a default value of 0 to a radtextbox in a radgrid if the value is null after databind?
-
30-05-2022 - |
문제
i have a series of radtextboxes as columns in a radgrid. The data they pull is often null. I'd like them to have a default value of zero in those cases. How do i accomplish this?
I tried this without success:
protected void rGrid_Inductions_PreRender(object sender, EventArgs e)
{
foreach (GridDataItem item in rGrid_Inductions.Items)
{
foreach (Control ctr in item.Controls)
{
if (ctr.GetType() == typeof(RadTextBox))
{
(ctr as RadTextBox).Text = "0" + (ctr as RadTextBox).Text;
}
}
}
rGrid_Inductions.Rebind();
}
Appreciate the help
해결책
다른 팁
You can definitely set the Default value when you drop the control on the page if you are creating the Control on Design View or on code behind http://www.telerik.com/help/aspnet-ajax/input-textbox-basics.html
Im puzzled as to why do you concatenate the text with the
(ctr as RadTextBox).Text = "0" + (ctr as RadTextBox).Text;
Is the 0 supposed to be permanent regardless of the text? Can you show me a sample Text?
However if all you want is the 0 as default, all you have to do is assign the value on design time or code behind like in the documentation that I posted above.