X
xzzy
For each row in a dataset bound to a datagrid, each row can differ by MyType
( ie 1, 2, 3, . . . ).
for different MyType, I need to call different javascript functions and pass
the values corresponding DataRow of the datagrid's cells
Problem: no values are passed to the javascript functions,
or said another way,
how does one get the value of a column in the DataRowItem of a
DataGrid at OnItemDataBound?
protected void DataGrid_ItemDataBound(object sender, DataGridItemEventArgs
e)
{
try
{
if ( e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem )
{
int myType =
Convert.ToInt32(ctlSearchResults.SelectedItem.Cells[1].Text);
switch ( myType )
{
case 1:
//Problem:
// These do not work:
// 1. ctlSearchResults.SelectedItem.Cells[2].Text, or
// 2. DataBinder.Eval(Container.DataItem, "MyColumn"), or
// 3. (DataRowView)Container.DataItem, etc.
//
e.Item.Attributes.Add("onclick",
"MyClientSideFunction01("+ ctlSearchResults.SelectedItem.Cells[2].Text) +
"," + ctlSearchResults.SelectedItem.Cells[3].Text + ")");
break;
Thank you,
John
( ie 1, 2, 3, . . . ).
for different MyType, I need to call different javascript functions and pass
the values corresponding DataRow of the datagrid's cells
Problem: no values are passed to the javascript functions,
or said another way,
how does one get the value of a column in the DataRowItem of a
DataGrid at OnItemDataBound?
protected void DataGrid_ItemDataBound(object sender, DataGridItemEventArgs
e)
{
try
{
if ( e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem )
{
int myType =
Convert.ToInt32(ctlSearchResults.SelectedItem.Cells[1].Text);
switch ( myType )
{
case 1:
//Problem:
// These do not work:
// 1. ctlSearchResults.SelectedItem.Cells[2].Text, or
// 2. DataBinder.Eval(Container.DataItem, "MyColumn"), or
// 3. (DataRowView)Container.DataItem, etc.
//
e.Item.Attributes.Add("onclick",
"MyClientSideFunction01("+ ctlSearchResults.SelectedItem.Cells[2].Text) +
"," + ctlSearchResults.SelectedItem.Cells[3].Text + ")");
break;
Thank you,
John