Solved

How do I pass arguments to an OnDataBinding function?

Posted on 2004-10-03
4
1,684 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
  • 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 250 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now