Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

I am getting error Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.

$
0
0

Hi 

In gridview ,if i click edit button,i am getting error in edititemtemplate

 "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control."

<asp:TemplateField HeaderText="Gender"><EditItemTemplate><asp:DropDownList ID="cmbGender" runat="server"  SelectedValue='<%# Eval("Gender") %> '><asp:ListItem Value="M" Text="Male"></asp:ListItem><asp:ListItem Value="F" Text="Female"></asp:ListItem></asp:DropDownList></EditItemTemplate><ItemTemplate><asp:Label ID="lbGender" runat="server" Text='<%# Eval("Gender")=="M" ? "Male" : "Female" %>'></asp:Label></ItemTemplate><FooterTemplate><asp:DropDownList ID="cmbNewGender" runat="server" ><asp:ListItem Selected="True" Text="Male" Value="M"></asp:ListItem><asp:ListItem Text="Female" Value="F"></asp:ListItem> </asp:DropDownList></FooterTemplate></asp:TemplateField>

In ItemTemplate if it is M Male is displayd and if it is F Female is displayed.

The same is not working in EditItemTemplate.Please help me to fix error

Thanks

Ram




Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>