?
Solved

How do I pass arguments to an OnDataBinding function?

Posted on 2004-10-03
4
Medium Priority
?
1,705 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month13 days, 21 hours left to enroll

801 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