set gridview cell text null
-
hi when click on edit button,I allow to update 2 columns.I want cell text of these colums should be null means user insert a new value. how it is possible? I used on editing event
protected void jgjgj(object sender, GridViewEditEventArgs e)
{
int index = e.NewEditIndex;
GridViewRow row=GridView4.Rows[index];//((TextBox)row.Cells\[5\].Controls\[0\]).Text = null; row.Cells\[4\].Text = ""; row.Cells\[5\].Text = ""; //GridViewRow row=gr this.Modalpopupextender1.Show(); }
but it is not working.
-
hi when click on edit button,I allow to update 2 columns.I want cell text of these colums should be null means user insert a new value. how it is possible? I used on editing event
protected void jgjgj(object sender, GridViewEditEventArgs e)
{
int index = e.NewEditIndex;
GridViewRow row=GridView4.Rows[index];//((TextBox)row.Cells\[5\].Controls\[0\]).Text = null; row.Cells\[4\].Text = ""; row.Cells\[5\].Text = ""; //GridViewRow row=gr this.Modalpopupextender1.Show(); }
but it is not working.
Once you assign new edit index, you have to bind the grid again. then later access the controls and assign the values to that. check this..
GridView4.EditIndex = e.NewEditIndex;
GridView4.Datasource = yourDataSource;
GridView4.DataBind();GridViewRow row = GridView4.Rows[4];
//IF the EditTemplate Contain textboxes..
TextBox txt = (TextBox)(row.FindControl("TextBoxID"));
txt.Text="";
txt = (TextBox)(row.FindControl("TextBoxID2"));
txt.Text="";with regards Karthik Harve
-
Once you assign new edit index, you have to bind the grid again. then later access the controls and assign the values to that. check this..
GridView4.EditIndex = e.NewEditIndex;
GridView4.Datasource = yourDataSource;
GridView4.DataBind();GridViewRow row = GridView4.Rows[4];
//IF the EditTemplate Contain textboxes..
TextBox txt = (TextBox)(row.FindControl("TextBoxID"));
txt.Text="";
txt = (TextBox)(row.FindControl("TextBoxID2"));
txt.Text="";with regards Karthik Harve
-
hi when click on edit button,I allow to update 2 columns.I want cell text of these colums should be null means user insert a new value. how it is possible? I used on editing event
protected void jgjgj(object sender, GridViewEditEventArgs e)
{
int index = e.NewEditIndex;
GridViewRow row=GridView4.Rows[index];//((TextBox)row.Cells\[5\].Controls\[0\]).Text = null; row.Cells\[4\].Text = ""; row.Cells\[5\].Text = ""; //GridViewRow row=gr this.Modalpopupextender1.Show(); }
but it is not working.
Try to this one:
GridView4.EditIndex = e.NewEditIndex;
string str = GridView4.DataKeys[e.NewEditIndex].Value.ToString();
GridViewRow row = (GridViewRow)grvCompType.Rows[e.NewEditIndex];
row.Cells[1].Text = ""; -
Try to this one:
GridView4.EditIndex = e.NewEditIndex;
string str = GridView4.DataKeys[e.NewEditIndex].Value.ToString();
GridViewRow row = (GridViewRow)grvCompType.Rows[e.NewEditIndex];
row.Cells[1].Text = "";