Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

linkbutton in a datalist

Status
Not open for further replies.

chris123321

IS-IT--Management
Joined
Mar 13, 2007
Messages
139
Location
US
On the mouseover, onclick, onmouseout the link button shows the javascript: _PostBack..

On the ItemDataBound event of the DataList, I added the code below:

Code:
CType(e.Item.FindControl("LinkButton1"), LinkButton).Attributes.Add("onMouseOver", "return statusMsg()")

for the onClick and onMouseOut events as well.

One issue is that the onClick event is not being triggered so when the user clicks on the linkbutton the javascript statusmsg doesn't show.

My next step is to show in the status bar. Any suggestions on what code I should add to window.status?

I had a hard time searching for this information on the web so any links would be appreciated.

Thanks.
 
My co-worker suggested I use a regular server control button in the datalist rather then the linkbutton server control.

However, the issue now is that if a user clicks on the button the ItemCommand event of the DataList doesn't get raised. Instead the ItemDataBound event gets raised, which doesn't make sense.

The link, says that the ItemCommand event gets raised when a button is clicked.

What do you guys think?
 
I think that event gets raised after the item databound.. trace through and see.
 
I clicked on a button in the datalist. The ItemDataBound event got raised and that's it. The ItemCommand Event did not get raised.
 
In the datalist of the aspx code, the OnItemCommand is equal to DataList1_ItemCommand, but again it doesn't get raised.
 
Ok.. it's because you have the link button in a datalist. What you have to do, is in the ItemDataBound event of the DataList, get a reference to the linkbutton. Then use addhandler to had a handler for the click event of the link button.
 
In the datalist of the aspx code, the OnItemCommand is equal to DataList1_ItemCommand, but again it doesn't get raised.
 
Sorry for the double post..

I'm using a regular server button control. Can you explain in further details of how to addhandler to add a handler for the click event of the link button?
 
As the data binds, the ItemdataBound event is fired for each row of data. On each row you have a link button, correct? In that event, get a refernce to the link button, something like:
Code:
'I don't know the exact syntax off the top of my head
   Dim lnkButton as new Linkbuttn
   lnkButton = e.Item.FindControl("yourlinkbuttonname")
   AddHandler lnkbutton.Click, AddressOf HandlerSub

    Private Sub HandlerSub(ByVal sender As Object, ByVal e As System.EventArgs)
        'Do Stuff Here
    End Sub
 
I dont see how including the addhandler code would help determine which row of the datalist the user clicked on and I need to know that so I could get the correct value from the dataset.

Code:
Session("Criteria") = tdsUserInfo.UserInfo(e.Item.ItemIndex).Criteria

Also, the datalist does not have a linkbutton server control, it has a button server control. When I had the linkbutton in the datalist, the ItemCommand event was being raised. That is not the case with using a button.

The problem with using the linkbutton was that when the user clicked on a linkbutton the statusbar would show javascript: _PostBack. I tried using javascript code to overwrite the statusbar message, but it still showed the javascript: _postback code.

Code:
CType(e.Item.FindControl("LinkButton1"), LinkButton).Attributes.Add("onMouseOver", "return statusMsg();")
 
I don't what to do to help you.. your posts are confusing and seem to be goin in circles..
 
I apologize..
how can I make my issue more clear?
 
Just please simply state what controls you are using and what exactly what functionality you want, and also simply explain what the issue(s) are that you are having.
 
Controls - datalist, linkbutton

Functionality - when the user hovers over the linkbutton the user will be able to see the Product ID in the status bar like in this example:

Issue - the MouseOver and MouseOut is correctly showing a statusMsg in JavaScript. The MouseUp, MouseDown, onClick is showing the javascript: _PostBack msg in the status bar instead of the status msg.

Please let me know if I still need to clarify on my issue.
 
MouseUp, Down and onClick will do a post back, that is why it is being shown by default. Not sure why you want to change that since the user will not really see it. If you really need to change it for some reason, then I suggest you post your problem in the javascript forum:forum216
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top