Reputation: 1859
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();
}
}
Upvotes: 0
Views: 1425
Reputation: 1798
You can use a GridView with EditTemplates. You can refer to this example for that.
It is possible to edit all rows of a GridView at the same time. Refer to this example.
You can optionally use Telerik's ASP.NET Data Grid that you can configure to work like excel using this example.
Upvotes: 0
Reputation: 19
I would like to suggest you to try listview, it allows you to edit the dynamic data, such as the content in textbox
Upvotes: 1