如何添加文本框模板以自动生成网格视图(ASP.NET)并从网格视图中复制少量列&将它们保存到另一列

时间:2017-08-21 09:47:22

标签: c# asp.net sql-server

这是我的网格视图前端

    <asp:GridView ID="GridView1" runat="server"> //This is auto generated grid view..

            <Columns>
               <asp:TemplateField HeaderText="Remarks">
        <ItemTemplate>
    <asp:TextBox ID="remarks" runat="server" Text=""></asp:TextBox> //This is the text box
 which i need to copy with some columns and save it in another table in sql server
 and i need to put this column as last column but it is coming as first
        </ItemTemplate>
    </asp:TemplateField>
            </Columns>

这是后端。我的主要疑问是如何从自动生成的网格中复制没有列号的列

    try
    {
        con.Open();
        GridView1.EmptyDataText = "No Records Found";
        GridView1.DataSource = cmd.ExecuteReader();
        GridView1.DataBind(); //how can i solve this? How to set the column in the last in auto generate columns
    }
    catch (Exception ex)
    {
        throw ex;
        //Message
    }
    finally
    {
        con.Close();
        con.Dispose();
    }
}

0 个答案:

没有答案