I got data from database into my datagridview via sqlDatasource1 i.e by using given tools, no programming et all.
I want to access rows of each Gridview row separately and then show them in textboxes of my own choice, instead of in gridview. How can I do that?
It works
numberOfRows = datagridview.Rows.Count;
but following doesn't
textbox1.Text=datagridview.Rows[0].cells[1].Text;
Dont know why it doesn;t?
Then I tried to get data of this gridview to another but it didn;t work too.
Help me plzzz.....I m struck here
Regards,
Mohsin
[email protected]
Loading
lovely nehaPosted Feb 26, 2009, 1:08 AM
hi..
and if u wants whole grid's data then use double loop ..
protected void btnCopy_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt = (DataTable)ViewState["table"];
for (int i = 0; i < dt.Rows.Count; i++)
{
for (int j = 0; j < dt.Columns.Count - 1; j++)
{
txtData.Text += dt.Rows[i][j] + ", ";
}
}
}
lovely nehaPosted Feb 26, 2009, 12:57 AM
hi..
try this..
protected void btnCopy_Click(object sender, EventArgs e){
DataTable dt = new DataTable();dt = (
DataTable)ViewState["table"]; for (int i = 0; i < dt.Rows.Count; i++){
txtData.Text += dt.Rows[i][1] +
", ";}
}