这个验证有点难~GridView(自动生成的)更新时验证。。。
一下是 GridView和数据源的全部代码。。帮忙看看怎么加验证啊。。。比如要某个字段只能是int。。。。每个字段都不为空什么的。。。怎么加验证?找了半天资料也没找到。。都是用的模板列做的。。。。要不就是手动写的跟新代码。。。。。。还有就是怎么在这个情况下加一个删除提示。。。。要是自己手动写的话。。我知道怎么写但是现在想知道在自动生成的这个情况下怎么写。。。。自动生成要别自己手动写要快很多啊。。。。高手帮看看啊<asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False"
DataKeyNames="类目ID" DataSourceID="SqlDataSource1" Width="506px" CellPadding="4" ForeColor="#333333" GridLines="None" OnRowDataBound="GridView1_RowDataBound" OnRowUpdating="GridView1_RowUpdating">
<Columns>
<asp:BoundField DataField="类目ID" HeaderText="类目ID" InsertVisible="False" ReadOnly="True"
SortExpression="类目ID" Visible="False" />
<asp:BoundField DataField="类目名称" HeaderText="类目名称" SortExpression="类目名称" />
<asp:BoundField DataField="档案类型" HeaderText="档案类型" SortExpression="档案类型" />
<asp:BoundField DataField="顺序" HeaderText="顺序" SortExpression="顺序" />
<asp:CommandField HeaderText="编辑|删除" ShowDeleteButton="True" ShowEditButton="True" DeleteText="<a href=# onclick="JavaScript:return confirm('确定删除吗?')">删除</a>" CausesValidation="False" />
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" CssClass="Freezing"/>
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:DangAnConnectionString %>" DeleteCommand="DELETE FROM [一级类目] WHERE [类目ID] = @original_类目ID AND [类目名称] = @original_类目名称 AND [档案类型] = @original_档案类型 AND [顺序] = @original_顺序"
InsertCommand="INSERT INTO [一级类目] ([类目名称], [档案类型], [顺序]) VALUES (@类目名称, @档案类型, @顺序)"
OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT [类目ID], [类目名称], [档案类型], [顺序] FROM [一级类目]"
UpdateCommand="UPDATE [一级类目] SET [类目名称] = @类目名称, [档案类型] = @档案类型, [顺序] = @顺序 WHERE [类目ID] = @original_类目ID AND [类目名称] = @original_类目名称 AND [档案类型] = @original_档案类型 AND [顺序] = @original_顺序">
<DeleteParameters>
<asp:Parameter Name="original_类目ID" Type="Int32" />
<asp:Parameter Name="original_类目名称" Type="String" />
<asp:Parameter Name="original_档案类型" Type="Int32" />
<asp:Parameter Name="original_顺序" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="类目名称" Type="String" />
<asp:Parameter Name="档案类型" Type="Int32" />
<asp:Parameter Name="顺序" Type="Int32" />
<asp:Parameter Name="original_类目ID" Type="Int32" />
<asp:Parameter Name="original_类目名称" Type="String" />
<asp:Parameter Name="original_档案类型" Type="Int32" />
<asp:Parameter Name="original_顺序" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="类目名称" Type="String" />
<asp:Parameter Name="档案类型" Type="Int32" />
<asp:Parameter Name="顺序" Type="Int32" />
</InsertParameters>
</asp:SqlDataSource>