C# 行上的Gridview命令
我正在尝试使用C# 行上的Gridview命令,c#,asp.net,gridview,C#,Asp.net,Gridview,我正在尝试使用onrow命令验证GridView 当我选择一个按钮时,它需要验证行delivery date,如果无效,则内联显示一条错误消息 目前,我的GridView设置如下: <asp:GridView ID="gvDistribution" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" Width="1000px" DataKeyNam
onrow命令验证GridView
当我选择一个按钮时,它需要验证行delivery date
,如果无效,则内联显示一条错误消息
目前,我的GridView
设置如下:
<asp:GridView ID="gvDistribution" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" Width="1000px" DataKeyNames="id" AllowPaging="True" OnPageIndexChanging="gvDistribution_PageIndexChanging" PageSize="5" OnRowCommand="gvDistribution_OnRowCommand" OnRowDataBound="gvDistribution_RowDataBound">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:BoundField DataField="name" HeaderText="Beneficiary Name"></asp:BoundField>
<asp:BoundField DataField="packingDate" HeaderText="Packing Date" DataFormatString="{0:dd/M/yyyy}"></asp:BoundField>
<asp:BoundField DataField="deliveryDate" HeaderText="Delivery Date" DataFormatString="{0:dd/M/yyyy}" />
<asp:TemplateField HeaderText="Status" ItemStyle-Width="120px">
<ItemTemplate>
<asp:Label ID="lblStatus" runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:ButtonField CommandName="View" Text="View Details" />
<asp:ButtonField CommandName="Action" Text="Action" />
<asp:TemplateField HeaderText="" ItemStyle-Width="120px">
<ItemTemplate>
<asp:Label ID="lblError" runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
问题是当交付日期得到验证时,每一行都会显示一条错误消息,而不仅仅是需要验证的那一行。
有人能告诉我如何在已验证的行中只强制执行一条消息吗?然后替换以开头的循环
foreach (GridViewRow g in gvDistribution.Rows){}
与
然后,替换以开头的循环
foreach (GridViewRow g in gvDistribution.Rows){}
与
然后,替换以开头的循环
foreach (GridViewRow g in gvDistribution.Rows){}
与
然后,替换以开头的循环
foreach (GridViewRow g in gvDistribution.Rows){}
与
我通过使用编辑部分中的代码进行修复。你的工作也很好。感谢alotI通过使用编辑部分中的代码修复。你的工作也很好。感谢alotI通过使用编辑部分中的代码修复。你的工作也很好。感谢alotI通过使用编辑部分中的代码修复。你的工作也很好。非常感谢