M
mg
I have a DataGrid with 2 Button Columns of type LinkButton
in a WebForm.
The DataGrid is populated:
private void Page_Load(object sender, System.EventArgs e)
{
if (! IsPostBack)
{
DataAdapter1.Fill(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.Cells[0].Text" brings back nothing. [Clues?
e.Item.Cells.ToString()
returns "System.Web.UI.WebControls.TableCellCollection"
and e.Item.Cells[0].ToString()
returns "System.Web.UI.WebControls.TableCell"]
private void DataGrid1_ItemCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs 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(object sender, System.EventArgs e)
{
if (! IsPostBack)
{
DataAdapter1.Fill(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.Cells[0].Text" brings back nothing. [Clues?
e.Item.Cells.ToString()
returns "System.Web.UI.WebControls.TableCellCollection"
and e.Item.Cells[0].ToString()
returns "System.Web.UI.WebControls.TableCell"]
private void DataGrid1_ItemCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs 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?