Hi
In below Gridview i want last column Date to be Editable
DataTable BookPlanningResult = sQLUtility.GeBookPlanningRecommendation(vRpl, BookCollection, StudentCollection).Tables[0];
if (BookPlanningResult != null)
{
DataColumn Remarks = new DataColumn("Remarks", typeof(string));
BookPlanningResult.Columns.Add(Remarks);
DataColumn Dates = new DataColumn("Date", typeof(DateTime));
BookPlanningResult.Columns.Add(Dates);
grdPlanning.DataSource = BookPlanningResult;
grdPlanning.DataBind();
}
Thanks
Naimish MakwanaPosted May 1, 2023, 4:55 AM
To make the last column "Date" editable in the GridView, you need to add an Edit button to each row and handle its click event to enable editing mode for the row. You can use the following code to achieve this:
1.Add a TemplateField to the GridView for the Edit button and set its CommandName to "Edit":
2.Handle the RowCommand event of the GridView and enable editing mode for the row if the CommandName is "Edit":
3. Bind the GridView data and set the TextBox control for the "Date" column to be editable when the row is in edit mode:
4. Finally, add a TextBox control to the ItemTemplate and EditItemTemplate of the "Date" column:
Thanks
Amit MohantyPosted May 1, 2023, 4:34 AM
To make the last column "Date" editable in the GridView, you can add a TemplateField column to the GridView's Columns collection.
You also need to set its "EditIndex" property to the index of the row being edited, either in code-behind or in response to a user action.