[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How do I pass arguments to an OnDataBinding function?

Posted on 2004-10-03
4
Medium Priority
?
1,714 Views
Last Modified: 2012-08-13
I have a linkButton inside a repeater and I call a function OnDataBinding to add a client side confirm prompt to it. I would like to know how I can pass an argument into this function so I can pass in a string to use as the prompt.

Here is what my link button looks like currently...

<ASP:LinkButton ID="deleteLink" RunAt="Server" OnDataBinding='AddConfirmToLink' OnCommand="ProcessArticleCmd" CommandName="ProcessArticleCmd_delete" CommandArgument='<%# DataBinder.Eval(Container.DataItem,"recordID") %>' Text="Delete" CausesValidation="False" />


Thanks :)

b
0
Comment
Question by:WillyCornbread
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 10

Expert Comment

by:jnhorst
ID: 12214487
Add the prompt string to your command argument.

CommandArgument='<%# DataBinder.Eval(Container.DataItem,"recordID") & ":PromptHere" %>'

If you pass the CommandArgument into the function, you can do something like this:

Dim ca As String() = "recID:Prompt".Split(":".ToCharArray())
Dim sID As String = ca(0)
Dim sCA As String = ca(1)

The sID would have the record id and the sCA would have the command argument.

John
0
 

Author Comment

by:WillyCornbread
ID: 12217344
I was under the impression that the CommandArgument was only available to the OnCommand event handler and not to both the OnDataBinding and OnCommand. Can you please confirm that this is NOT the case and I will test your suggestion?


Thanks!

b
0
 
LVL 10

Accepted Solution

by:
jnhorst earned 1000 total points
ID: 12221365
My bad in the sense that I thought you were using the ItemDataBound event, which is what I would suggest you try:

If you want to configure the buttons that appear in repeater items, use the ItemDataBound event like this:  Let's say your button is named cmdPromptConfig.

If e.Item.ItemType <> ListItemType.Header And e.Item.ItemType <> ListItemType.Footer Then
     ' resolve control.
     Dim btn As Button = CType(e.FindControl("cmdPromptConfig", Button)

     ' call your routine, passing the instance of the button, to configure it for the prompt.  you will have access
     ' to the CommandArgument which should have been set from your data binding code.
End If

John
0
 

Author Comment

by:WillyCornbread
ID: 12221548


Thanks, that will work :)

Much appreciated.

b
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question