gettting data from gridview in edit mode text cont
actually i want to get data for updaion in edit mode how i can data from text control when row in edit mode and click the update button
there is code through which i m trying bu t this code give me data which is in cell not in test box place over cell in edit mode
public void UpdateGridRecord()
{
string firstname;
string lastname;
string city;
string pid;
//pid=Convert.ToInt32(gvPerson.Rows[RowToChange].Cells[1].Text);
//pid = gvPerson.Rows[RowToChange].Cells[1].Text;
//firstname = Convert.ChangeType(gvPerson.Rows[RowToChange].Cells[2].Controls[0], TextBox).ToString();
//lastname=gvPerson.Rows[RowToChange].Cells[3].Text;
//city=gvPerson.Rows[RowToChange].Cells[4].Text;
if (Convert.ChangeType(gvPerson.Rows[RowToChange].Cells[2].Controls[0], typeof(TextBox)) != null)
{
firstname = ((TextBox)gvPerson.Rows[RowToChange].Cells[2].Controls[0]).Text;
}
if (Convert.ChangeType(gvPerson.Rows[RowToChange].Cells[3].Controls[0], typeof(TextBox)) != null)
{
lastname = ((TextBox) Convert.ChangeType(gvPerson.Rows[RowToChange].Cells[3].Controls[0],typeof(TextBox))).Text;
}
if (Convert.ChangeType(gvPerson.Rows[RowToChange].Cells[4].Controls[0], typeof(TextBox)) != null)
{
city = ((TextBox)gvPerson.Rows[RowToChange].Cells[4].Controls[0]).Text;
}
//txtChildName = CType(grdchildgrid.Rows(intRowId).Cells(3).Control s(0), TextBox).Text
DSPerson.UpdateParameters["personid"].DefaultValue = pid;
DSPerson.UpdateParameters["firstname"].DefaultValue = firstname;
DSPerson.UpdateParameters["lastname"].DefaultValue = lastname;
DSPerson.UpdateParameters["city"].DefaultValue = city;
DSPerson.Update();
}
please help me
|