S
Solomon Shaffer
I have a datagrid that I am adding a template column to (containing a couple
of linkbuttons) at runtime and am having some difficulty setting the
commandargument or the linkbuttons. Does anyone know the syntax to databind
the commandargument to the row through code. I am assumning I use the
DataBinder.Eval method but I cannot get it going. Below is the code sample.
Thanks
Solomon
public class KnowlagentDataGridTemplate : ITemplate
{
private ArrayList m_arActionColumnItems;
public DataGridTemplate( ArrayList ActionColumnItems )
{
m_arActionColumnItems = ActionColumnItems;
}
public void InstantiateIn( System.Web.UI.Control oContainer )
{
//Add a new link button for each action in the actions array
for ( int i = 0; i < m_arActionColumnItems.Count; i++ )
{
ActionColumnItem oActionColumnItem =
(ActionColumnItem)m_arActionColumnItems;
LinkButton lnkAction = new LinkButton();
lnkAction.Text = oActionColumnItem.ActionText;
lnkAction.CommandArgument = ******DataBinder.Eval( oContainer.DataItem,
oActionColumnItem.CommandArgument );*****//This not working
//lnkAction.CommandArgument = oActionColumnItem.CommandArgument;
lnkAction.CommandName = oActionColumnItem.ActionText;
lnkAction.Attributes.Add("runat","server");
lnkAction.ID = "lnkAction" + i;
oContainer.Controls.Add( lnkAction );
if ( i < m_arActionColumnItems.Count - 1 )
{
oContainer.Controls.Add( new LiteralControl( " | " ) );
}
}
}
}
public class ActionColumnItem
{
protected string sActionText;
protected string sCommandArgument;
public string ActionText
{
get
{
return sActionText;
}
set
{
sActionText = value;
}
}
public string CommandArgument
{
get
{
return sCommandArgument;
}
set
{
sCommandArgument = value;
}
}
public ActionColumnItem( string ActionText, string CommandArgument )
{
sActionText = ActionText;
sCommandArgument = CommandArgument;
}
}
of linkbuttons) at runtime and am having some difficulty setting the
commandargument or the linkbuttons. Does anyone know the syntax to databind
the commandargument to the row through code. I am assumning I use the
DataBinder.Eval method but I cannot get it going. Below is the code sample.
Thanks
Solomon
public class KnowlagentDataGridTemplate : ITemplate
{
private ArrayList m_arActionColumnItems;
public DataGridTemplate( ArrayList ActionColumnItems )
{
m_arActionColumnItems = ActionColumnItems;
}
public void InstantiateIn( System.Web.UI.Control oContainer )
{
//Add a new link button for each action in the actions array
for ( int i = 0; i < m_arActionColumnItems.Count; i++ )
{
ActionColumnItem oActionColumnItem =
(ActionColumnItem)m_arActionColumnItems;
LinkButton lnkAction = new LinkButton();
lnkAction.Text = oActionColumnItem.ActionText;
lnkAction.CommandArgument = ******DataBinder.Eval( oContainer.DataItem,
oActionColumnItem.CommandArgument );*****//This not working
//lnkAction.CommandArgument = oActionColumnItem.CommandArgument;
lnkAction.CommandName = oActionColumnItem.ActionText;
lnkAction.Attributes.Add("runat","server");
lnkAction.ID = "lnkAction" + i;
oContainer.Controls.Add( lnkAction );
if ( i < m_arActionColumnItems.Count - 1 )
{
oContainer.Controls.Add( new LiteralControl( " | " ) );
}
}
}
}
public class ActionColumnItem
{
protected string sActionText;
protected string sCommandArgument;
public string ActionText
{
get
{
return sActionText;
}
set
{
sActionText = value;
}
}
public string CommandArgument
{
get
{
return sCommandArgument;
}
set
{
sCommandArgument = value;
}
}
public ActionColumnItem( string ActionText, string CommandArgument )
{
sActionText = ActionText;
sCommandArgument = CommandArgument;
}
}