在GridView中设置默认值 [英] set default value in gridview
本文介绍了在GridView中设置默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在添加新记录时在gridview的每一列中设置默认值我该怎么做
i want to set default value in each column of gridview when add new record how can i do this
推荐答案
EditColumns-> DefaultCellStyle中有一个属性-> NullValue.将此属性设置为所需的值.
There is a property in EditColumns->DefaultCellStyle->NullValue.Set this property as your desired value.
尝试:
<asp:TextBox runat="server"
Text='<%#DefaultVal(Eval("FieldName").ToString())% >' ID="txtBox1"
></asp:TextBox>
并在代码背后:
and in the codeBehind:
protected string DefaultVal(string val)
{
if(val == null)
return("0");
else
return(val);
}
这篇关于在GridView中设置默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文