Button with multiple CommandArguments??

J

Jan Vetterli

hi,

I'm wondering how I can achieve a button with a CommandArgument thats
dynamicly created from two or more DataBinder values, seperated with a ";"
so I can split the information up afterwards.


I've tried this (on the HTML page):

<asp:Button ID="NewButton" Runat="server" Text="New"
CommandName = "New"
CommandArgument ='<%# DataBinder.Eval(Container.Item, "ID")%> & ";" &
<%# DataBinder.Eval(Container.Item, "Name")%>'
</asp:Button>


With this code, I'll alway get an error msg. Can anybody help, please?

Thanks

Jan
 
J

Joe Molloy

I think we need to see the bigger picture here Jan - what are you trying to
achieve with this behaviour - maybe we can spot alternative approaches.

Joe
 
J

Jan Vetterli

Hi Joe

This button will be placed in a Datarepeater ctrl. I want to use the
information thats included in the CommandArgument to supply me with
information like: how many times this item has been clicked and the ID of
the selected content of the Datarepeater. I can not use the CommandName for
this since I need it allready to supply me with more information from the
database.

I've found a way around this by just get the ID and execute a database
lookup, read the field with the stored information on how many times it has
been clicked, add 1 and write the new total of the click counter back to the
database.

I just thought it would be faster and easier to supply the value of the
click counter in the Datarepeater, and I really think there must be a way to
include two information strings in the CommandArgument.

Jan
 
Joined
Jul 26, 2007
Messages
1
Reaction score
0
I had this same problem here is how I solved it.


OnCommand="command_Click"
CommandArgument='<%# (Container.DataItem).String1 + "," + (Container.DataItem).String2 %>'

public void command_Click(object sender, EventArgs e)
{

string[] commandArgs = e.CommandArgument.ToString().Split(new char[] {','});

string1 = commandArgs[0];
string2 = commandArgs[1];
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top