473,793 Members | 2,974 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 KnowlagentDataG ridTemplate : ITemplate
{
private ArrayList m_arActionColum nItems;

public DataGridTemplat e( ArrayList ActionColumnIte ms )
{
m_arActionColum nItems = ActionColumnIte ms;
}

public void InstantiateIn( System.Web.UI.C ontrol oContainer )
{
//Add a new link button for each action in the actions array
for ( int i = 0; i < m_arActionColum nItems.Count; i++ )
{
ActionColumnIte m oActionColumnIt em =
(ActionColumnIt em)m_arActionCo lumnItems[i];
LinkButton lnkAction = new LinkButton();
lnkAction.Text = oActionColumnIt em.ActionText;
lnkAction.Comma ndArgument = ******DataBinde r.Eval( oContainer.Data Item,
oActionColumnIt em.CommandArgum ent );*****//This not working
//lnkAction.Comma ndArgument = oActionColumnIt em.CommandArgum ent;
lnkAction.Comma ndName = oActionColumnIt em.ActionText;
lnkAction.Attri butes.Add("runa t","server") ;
lnkAction.ID = "lnkAction" + i;
oContainer.Cont rols.Add( lnkAction );

if ( i < m_arActionColum nItems.Count - 1 )
{
oContainer.Cont rols.Add( new LiteralControl( "&nbsp;|&nb sp;" ) );
}
}
}
}

public class ActionColumnIte m
{
protected string sActionText;
protected string sCommandArgumen t;

public string ActionText
{
get
{
return sActionText;
}
set
{
sActionText = value;
}
}

public string CommandArgument
{
get
{
return sCommandArgumen t;
}
set
{
sCommandArgumen t = value;
}
}

public ActionColumnIte m( string ActionText, string CommandArgument )
{
sActionText = ActionText;
sCommandArgumen t = CommandArgument ;
}
}
Nov 18 '05 #1
0 1563

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

Similar topics

2
6504
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 value, so one query might return players from multiple schools; clicking on a player row's school linkbutton will filter the previous query to that school. The linkbuttons bind properly (including the commandArgument) when the templatecolumn is...
2
2671
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 can't see why. can anyone tell me why this chunk of code works: <asp:datagrid id="DataGrid1" style="Z-INDEX: 104; LEFT: 16px; POSITION: absolute; TOP: 136px" runat="server" CellPadding="3" OnItemDataBound="DataGridBindEvent"...
2
2789
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"> <HeaderStyle Width="30%" CssClass="folderHeader"></HeaderStyle> <ItemTemplate>
2
4946
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 UI Dim arg As String = sender.CommandArgument is the code from: http://www.4guysfromrolla.com/webtech/082901-1.2.shtml
2
6029
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 fine. However, e.CommandArgument is an empty string, presumably because the CommandArgument property of the ImageButtons is not set. Is there some way, in the markup, to set the CommandArgument to the row index? <ItemTemplate>
3
9453
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='<%# DataBinder.Eval(Container.DataItem, "EmpId")%>' ....> In the .aspx.vb file I am referring this value as..
1
4610
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 acting as if I did not set it). Here is my code that sets the CommandArgument property in the ItemDataBound event: CType(e.Item.FindControl("btnMainMoveDown"), Button).CommandArgument = CStr(CType(Me.datMain.DataSource,...
1
13309
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 ImageButton I needed to redirect the user to the Edit page where the data on the page would be prepopulated with data from the database. I tried several things without success then discovered that the CommandArgument property could be used for this...
1
2993
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 e.CommandArgument being passed into the RowCommand event handler is always coming back as an empty string and causing an invalid cast exception. The GridView itself has a hyperlink field to display the object name, and several TemplateFields to...
0
9518
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10430
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10000
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9033
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3719
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2917
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.