日期:2014-05-18  浏览次数:20737 次

datagrid编辑列问题**************
web程序 ,datagrid 动态增加的列(列不固定),怎么在datagrid后增加编辑列,并且点击编辑后只修改数值型的列(已知道那个列是数值型)
在grid前边增加编辑列,我能实现,但是客户要求把编辑列放grid后边

------解决方案--------------------
HTML code

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" PageSize="10" 

                        Width="542px" AllowPaging="True" AllowSorting="True"

                         DataKeyNames="DB31_1,DB31_2" OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowDeleting="GridView1_RowDeleting" OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating" OnPageIndexChanging="GridView1_PageIndexChanging" OnRowDataBound="GridView1_RowDataBound" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" OnSorting="GridView1_Sorting" >

                        <Columns>

                            <asp:TemplateField HeaderText="序号">

                                <ItemTemplate>

                                <%# this.GridView1.PageIndex * this.GridView1.PageSize + this.GridView1.Rows.Count + 1%>

                                </ItemTemplate>

                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="学历代码" SortExpression="DB1_1">

                                <EditItemTemplate>

                                    <%--<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("DB1_1") %>'></asp:TextBox>--%>

                               <asp:DropDownList ID ="ddlXL" runat="server"  DataValueField='<%# Bind("DB1_1") %>'></asp:DropDownList>

                                </EditItemTemplate>

                                <ItemTemplate>

                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("xueliText") %>'></asp:Label>

                                </ItemTemplate>

                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="学历名称" SortExpression="DB1_2">

                                <EditItemTemplate>

                                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("DB1_2") %>'></asp:TextBox>

                                </EditItemTemplate>

                                <ItemTemplate>

                                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("DB1_2") %>'></asp:Label>

                                </ItemTemplate>

                            </asp:TemplateField>

                          

                        <asp:TemplateField HeaderText="操作" ShowHeader="False">

                        <EditItemTemplate>

                            <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"

                                 Text="更新"></asp:LinkButton>

                            <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"

                                Text="取消"></asp:LinkButton>

                        </EditItemTemplate>

                        <ItemTemplate>

                            <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"