By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,022 Members | 1,198 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,022 IT Pros & Developers. It's quick & easy.

Gridview default cell value???

P: n/a
HI all,

I'm returning a dataset to a gridview control. When the gridview asp.net
control is populated from the returning dataset some of the cells remain
empty. This is expected as some data in the dataset is empty. The cells
that are empty, in the gridview control, I would like to have the value of 0
(zero) inserted. Is there a default cell value property or something similar
for the asp.net gridview control. So if no data is returned to that cell a 0
(zero) is shown.

Thanks in advance.

--
Message posted via http://www.dotnetmonster.com
Feb 24 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
You can program the RowDataBound event to set default values for null entries:
http://msdn2.microsoft.com/en-us/lib...nd(VS.80).aspx

Or you can replace the BoundFields with TemplateFields where the server
controls have conditional databinding expressions to display a default value
if the field value were null, e.g.
<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);

}
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Jon S via DotNetMonster.com" wrote:
HI all,

I'm returning a dataset to a gridview control. When the gridview asp.net
control is populated from the returning dataset some of the cells remain
empty. This is expected as some data in the dataset is empty. The cells
that are empty, in the gridview control, I would like to have the value of 0
(zero) inserted. Is there a default cell value property or something similar
for the asp.net gridview control. So if no data is returned to that cell a 0
(zero) is shown.

Thanks in advance.

--
Message posted via http://www.dotnetmonster.com

Feb 24 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.