I have a DataGrid with 2 Button Columns of type LinkButton
in a WebForm.
The DataGrid is populated:
private void Page_Load(objec t sender, System.EventArg s e)
{
if (! IsPostBack)
{
DataAdapter1.Fi ll(dataSet11);
Page.DataBind() ;
}
}
I'm able to detect which column was selected by clicking
on one column and seeing "LEFT" displayed or the other
column and seeing "RIGHT" displayed in a Label. But, I'm
not able to get the data in an individual cell. That
is, "e.Item.Cel ls[0].Text" brings back nothing. [Clues?
e.Item.Cells.To String()
returns "System.Web.UI. WebControls.Tab leCellCollectio n"
and e.Item.Cells[0].ToString()
returns "System.Web.UI. WebControls.Tab leCell"]
private void DataGrid1_ItemC ommand(object source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs e)
{
if (e.CommandName == "Select1")
Label1.Text = e.Item.Cells[0].Text; // returns nothing
//Label1.Text = "LEFT";
}
else
{ {
Label1.Text = e.Item.Cells[1].Text; // returns nothing
//Label1.Text = "RIGHT";
}
}
How can I see the data contents of an individual cell of
the DataGrid?
in a WebForm.
The DataGrid is populated:
private void Page_Load(objec t sender, System.EventArg s e)
{
if (! IsPostBack)
{
DataAdapter1.Fi ll(dataSet11);
Page.DataBind() ;
}
}
I'm able to detect which column was selected by clicking
on one column and seeing "LEFT" displayed or the other
column and seeing "RIGHT" displayed in a Label. But, I'm
not able to get the data in an individual cell. That
is, "e.Item.Cel ls[0].Text" brings back nothing. [Clues?
e.Item.Cells.To String()
returns "System.Web.UI. WebControls.Tab leCellCollectio n"
and e.Item.Cells[0].ToString()
returns "System.Web.UI. WebControls.Tab leCell"]
private void DataGrid1_ItemC ommand(object source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs e)
{
if (e.CommandName == "Select1")
Label1.Text = e.Item.Cells[0].Text; // returns nothing
//Label1.Text = "LEFT";
}
else
{ {
Label1.Text = e.Item.Cells[1].Text; // returns nothing
//Label1.Text = "RIGHT";
}
}
How can I see the data contents of an individual cell of
the DataGrid?
Comment