This is my code in aspx:
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="SqlDataSource2" SelectedValue='<%#GetSYSACCID(Eval("SYSACCID"))%>'
DataTextField="UserName" DataValueField="SYSACCID">
</asp:DropDownList>
</EditItemTemplate>
DropDownList is inside EditItemTemplate of TemplateField in gridview. The GetSYSACCID is a function defined in aspx.cs. Problem is when Eval("SYSACCID") is null, GetSYSACCID returns null and so error is thrown. How can I handle this? I know this looks easy but still it’s giving me a pain.
Thanks in advance 🙂
You can do something like…
You have default value to handle null value. e.g.