使用LinqDataSource和DropDownlist在GridView中编辑时出错 [英] Error with Edit in GridView using LinqDataSource and DropDownlist
问题描述
大家好,我和他们在这里很新!
Hi everybody, I´m new here!
当我尝试在gridView中编辑时,我对linqDataSource和我的DropDownList有很多麻烦,但我知道问题出在哪里但是我并不敏锐地知道解决方案在哪里!
I having much trouble with linqDataSource and my DropDownList when I try to edit in gridView, but I know where is the problem but I don´t have a clue where is the solution!
问题:
遵循本教程 http://weblogs.asp.net/ scottgu / archive / 2007/05/29 / linq-to-sql-part-2-defining-our-data-model-classes.aspx I
使我的GridView与LinqDataSource一起工作正常,我可以编辑或删除我的条目!
Following this tutorial http://weblogs.asp.net/scottgu/archive/2007/05/29/linq-to-sql-part-2-defining-our-data-model-classes.aspx I make my GridView with LinqDataSource working fine, I can edit or delete my entries !
真正的交易是当我尝试编辑一行并且我的DOSESUBCITEM列中有一个空值(其中是DropDownList)没有任何反应! !!
The real deal is when I trying to edit a row and I have a null value in my DOSESUBCITEM column (where is a DropDownList) nothing happens!!!
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" SkinID="TableDefault"
DataKeyNames="doseitem1" DataSourceID="DOSEITEMLinqDataSource"
AllowPaging="True" AllowSorting="True">
<Columns>
<asp:TemplateField HeaderText="Código" SortExpression="codi_item">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("codi_item") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("codi_item") %>'></asp:Label>
</EditItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Descrição" SortExpression="desc_item">
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("desc_item") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("desc_item") %>'></asp:Label>
</EditItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Droga" SortExpression="dosedrog">
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("dosedrog") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("dosedrog") %>'></asp:Label>
</EditItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Genérico" SortExpression="dosegene">
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("dosegene") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("dosegene") %>'></asp:Label>
</EditItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>
推荐答案
Hello Wagner,
Hello Wagner,
欢迎来到MSDN论坛,感谢您在此发帖。
Welcome to the MSDN Forum and thanks for posting here.
根据您的描述,我的理解是,如果您在DOSESUBCITEM下拉列表中选择空值,则有没有结果回报。我是对的吗?
According to your description, my understanding is if you choose null value in your DOSESUBCITEM dropdownlist, there is no result return. Am I right?
如果是这样,我认为您可能需要在后面的代码中添加判断声明。如果选择空值,则返回所有数据。然后绑定到gridview。
If so, I think you may need to add a judgment statement in your behind code. To let return all data if you choose a null value. Then bind to the gridview.
如果我误解了你,请随时告诉我。如果是这样,您能否向我们展示有关错误和背后代码的更多信息?
Please feel free to tell me if I misunderstood you. If so, could you please show us more information about the error and your behind code?
我希望它可以提供帮助。
I hope it can help.
祝你有个美好的一天,
这篇关于使用LinqDataSource和DropDownlist在GridView中编辑时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!