|
-
Feb 10th, 2010, 09:50 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] how can be added vb code in the html code?
my new problem is that i want to add the session.add() command in the datagrid when a hyperlink button of a datagrid is pushed
i want to store a value(to use it to another page of the site) and i think i have to do that..
does anyone know how can i put the session add command(or any other vb.net command) in the html hyperlink??
i thik somehow like this
<ItemTemplate>
<asp:HyperLink ID="HyperLink2" runat="server" onclick="<%# %>" NavigateUrl='<%# databinder.eval(container.dataitem,"url") %>' Text='<%# databinder.eval(container.dataitem,"titlos") %>'></asp:HyperLink>
</ItemTemplate>
but how exactly??
-
Feb 10th, 2010, 02:41 PM
#2
Re: how can be added vb code in the html code?
Hey,
The short answer is that you can put code directly in the ASPX markup.
The slightly longer answer is that you shouldn't. You shouldn't mix server side code with your ASPX markup, put that code where it belongs, on the ServerSide.
For the sake of clarity, when you talk about a DataGrid, is this actually what you are using, or are you actually using a GridView?
Gary
-
Feb 11th, 2010, 03:39 AM
#3
Re: how can be added vb code in the html code?
Use a LinkButton instead - it will cause a postback and you'll have to handle the RowCommand/ItemCommand event. You can add the item to session there.
-
Feb 11th, 2010, 12:40 PM
#4
Thread Starter
Hyperactive Member
Re: how can be added vb code in the html code?
with the linkbutton now i must find the number of the row and column that i am
something like this??
Protected Sub ela(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs)
Dim id As Integer = e.Item.Cells.GetCellIndex
Response.Write(ID)
End Sub
but how exactly can i find the datagrids row and column in which is the button that has been pushed??
Last edited by vagelis; Feb 11th, 2010 at 02:44 PM.
-
Feb 11th, 2010, 02:59 PM
#5
Re: how can be added vb code in the html code?
Hey,
In addition to setting the CommandName of the LinkButton, set the CommandArgument. You can set this on the RowDataBound event, or, as described here:
http://www.west-wind.com/Weblog/posts/88462.aspx
Gary
-
Feb 11th, 2010, 04:01 PM
#6
Thread Starter
Hyperactive Member
Re: how can be added vb code in the html code?
that was a very good suggestion..!!
it works fine..thank you Gary!!
-
Feb 12th, 2010, 03:23 AM
#7
Re: [RESOLVED] how can be added vb code in the html code?
Hey,
Glad to hear that you got it working!!
Gary
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|