I have a gridview which I used to display tabular data. I want the users to edit the field values and save it. Is there any way to add a textbox in place of bound field. This is my gridview.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
Height="186px" Width="325px">
<Columns>
</Columns>
</asp:GridView>
This is the code behind which populate the GridView
public List<DataControlField> columns = new List<DataControlField>();
public object DataSource { get; set; }
protected void Page_Init(object sender, EventArgs e)
{
for (int i = 0; i < 10; i++)
{
BoundField bf = new BoundField() ;
bf.HeaderText = "LastName" ;
bf.DataField = "LastName";
columns.Add(bf);
}
foreach (DataControlField col in columns)
{
GridView1.Columns.Add(col);
}
}
protected void Page_Load(object sender, EventArgs e)
{
List<Data> lastN = new List<Data>() ;
for(int i = 0 ; i < 50; i++ )
{
lastN.Add(new Data(i.ToString()));
}
GridView1.DataSource = lastN;
GridView1.DataBind();
}
}
我想建议您尝试使用listview,它可以让您编辑动态数据,例如文本框中的内容
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.