Click here to Skip to main content
15,996,848 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
inside gridview i have added following labels , if their is no values inside database i want to display following labels, so i can edit that fields and update data inside gridview, guys if you know something about it will very helpful for me.
<asp:TemplateField >
  <itemtemplate>
  <asp:Label runat="server" ID="lblname" class="form-control" Text="Name">
  <asp:Label runat="server" ID="lblphone" class="form-control" Text="Phone">  
  <asp:Label runat="server" ID="lblemail" class="form-control" Text="Email">
  <asp:Label runat="server" ID="lblcurentadd" class="form-control" Text="Current Address">
  <asp:Label runat="server" ID="lblperadd" class="form-control" Text="Permanent Address">
 </itemtemplate>
<asp:TemplateField  >
 <itemtemplate>
     <asp:Label ID="lblnamea" class="form-control" runat="server" Text='<%# Eval("user_name")%>'>
     <asp:Label ID="lblphonea" class="form-control" runat="server" Text='<%# Eval("phone")%>' >  
     <asp:Label ID="lblemaila" class="form-control" runat="server" Text='<%# Eval("email_id")%>'>
     <asp:Label ID="lblcurentadda" class="form-control" runat="server" Text='<%# Eval("current_address")%>'>
     <asp:Label ID="lblperadda"  class="form-control" runat="server" Text='<%# Eval("permanent_address")%>'>                                                                                                                                          </itemtemplate> 
Posted
Updated 3-Jan-16 2:17am
v3
Comments
[no name] 2-Jan-16 5:01am    
If you want edit, add functionality then follow below link:

http://www.dotnetfox.com/articles/how-to-add-edit-delete-update-records-in-grid-view-
Asp-Net-1003.aspx

1 solution

You can easily do this by ternary operator along with Eval.

Refer - Replace null value databind item with default value[^].
 
Share this answer
 
v2
Comments
Design5ud 2-Jan-16 7:17am    
i tried that code but its still displaying empty gridview
Show me the code.
Design5ud 4-Jan-16 0:34am    
it was not displaying because of session , i corrected it and the code is working. thank u tadit..
Glad to hear that. Most welcome. Keep coding. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900