Hi,
Using dataset how can we retrieve cell value in a gridview? I want the secong cell value. all columns are labels..I have used this method:
Dim label lblprod=Ctype(grv.Rows(e.RowIndex).FindControl("lblprod"),label)
Also used lblprod=grv.Rows(rowindex).Cells(1).Text.. But these are not fetching the cell value.. Based on which i need to update and delete the table... Is there any other way
DataSet.Table... like that?
I am a new bieee so plzzz try to understand me and plzz explain in simple words...
Thanx....
Loading

Subhendu DeRank #1,108 · 1.7K reputationPosted Dec 29, 2010, 8:47 PM EST
foreach (GridViewRow gdRow in gdr.Rows)
{
Label lbl = gdRow.FindControl("lblid") as Label;
obj.cmd.CommandText = "update tblitems set bill_number='" + billnum + "' where id='" + lbl.Text + "'";
obj.cmd.ExecuteNonQuery();
}
Subhendu DeRank #1,108 · 1.7K reputationPosted Dec 29, 2010, 2:17 AM EST
In order to give you a solution, please forward the code.
Dim lblprod as label = Ctype(grv.Rows(e.RowIndex).<access Cell code>FindControl("lblprod"),label)
lblprod.Text should give the value
Ananya Suhas65 reputationPosted Dec 29, 2010, 2:45 AM EST
private string billnumber() { string num = System.Guid.NewGuid().ToString(); int charCount = 0; foreach (char c in num) { if (char.IsDigit(c)) { billnum += c.ToString(); charCount += 1; } if (charCount == 6) { break; } } return billnum; } protected void btnbuy_Click(object sender, System.EventArgs e) { try { billnum = billnumber(); int rowcount = gvr.Rows.Count; obj.Connect(); for (int i = 0; iSuthish NairRank #92 · 22.8K reputationPosted Dec 29, 2010, 6:13 AM EST
int id = ((Label)gvr.Rows(i).Cells(1).FindControl("lblid")).Text;
Ananya Suhas65 reputationPosted Dec 30, 2010, 6:08 PM EST
Subhendu DeRank #1,108 · 1.7K reputationPosted Dec 30, 2010, 8:02 PM EST
So your requirement is to get the label within gridview in button click event.
That's why I iterate over each row of the gridview, find the control in the row and referencing it.
That's it.....