0

我有一系列 radtextboxes 作为 radgrid 中的列。他们提取的数据通常为空。在这些情况下,我希望它们的默认值为零。我如何做到这一点?

我试过这个没有成功:

    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();
    }

感谢帮助

4

2 回答 2

1

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.

于 2013-05-21T00:00:44.573 回答
1

为什么在创建它们时不设置 RadTextBox=0 的默认文本,然后在此(预渲染循环)中修改它们(如果它们不为空);

于 2013-05-20T19:46:54.693 回答