473,402 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

CommandArgument in TemplateColumn

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[i];
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( "&nbsp;|&nbsp;" ) );
}
}
}
}

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;
}
}
Nov 18 '05 #1
0 1540

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Benjamin Joldersma | last post by:
Hello all, My basic problem is that my LinkButton does not support a data bound CommandArgument property under certain cases. The intent is to filter my datagrid based on a specific row's...
2
by: jason | last post by:
i'm trying to set the commandargument property of a buttoncolumn in the DataGrid ItemBind event. it works fine in one instance, but in the latest page i've written it doesn't seem to work, and i...
2
by: Liza | last post by:
Hi I have a problem gettting the right data in my CommandArgument after I applyed a rowfilter. My template column looks somewhat like this: <asp:TemplateColumn HeaderText="ErrorID">...
2
by: needin4mation | last post by:
I have some VB.NET code that I am trying to convert. I'm not sure what to do here and was hoping you could help. Sub PagerButtonClick(sender As Object, e As EventArgs) 'used by external paging...
2
by: David | last post by:
I have a template field in a GridView that contains two ImageButtons. When the user clicks one of the buttons, the GridView's RowCommand event is fired and I can get the CommandName. All that is...
3
by: Renilkumar | last post by:
I have a datagrid using link button. I am setting the CommandArgument value as .. <asp:linkbutton runat="server" EnableViewState=True CommandArgument='<%#...
1
by: Nathan Sokalski | last post by:
I am trying to set the CommandArgument property of a Button control from a template in a DataList of mine using code in the ItemDataBound event. However, it does not want to set the property (it is...
1
nateraaaa
by: nateraaaa | last post by:
While working on a recent project I discovered how useful the CommandArgument property can be. I needed to determine the record_id of a row displayed in my datagrid. When the user clicked the Edit...
1
by: Leon Mayne | last post by:
Hello, I have a gridview that's bound to a generic list of business objects and am using the RowCommand event to capture user clicks on actions. This was working fine up until today, but now...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.