Reputation: 657
protected void GridView1_OnRowCommand(object sender, GridViewCommandEventArgs e)
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = GridView1.Rows[index];
k = row.Cells[0].ToString();
Label1.Text = k;
}
I want to get a value of a particular cell in the selected row.So I tried with this but this is giving very odd result the label printing the below text
System.Web.UI.WebControls.DataControlFieldCell.
Can anybody tell me how to solve my problem.
Upvotes: 1
Views: 2057
Reputation: 10354
Set the Command Argument as
CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>' CommandName = "QC"
And in the RowCommand Event
if (e.CommandName == "QC")
{
int RowIndex = Convert.ToInt32(e.CommandArgument);
Get the values u want based on the RowIndex.
Upvotes: 0
Reputation: 3885
Try this:
k = row.Cells[0].Text;
You'll get the text present in it.
Upvotes: 2
Reputation: 381
Use EventHandler Gridview_CellEdit or some similar to this. And then if (selecteditems.count>0) you can get a value of them. With creating a new variable, of course.
Upvotes: 0