Solved

How do I pass arguments to an OnDataBinding function?

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Host asp.net pages 5 33
Turn on intranet settings 1 55
ASP.net Show "please wait " message as page loads 2 39
jquery datatables, asp.net MVC 9 38
I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

816 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

8 Experts available now in Live!

Get 1:1 Help Now