3 Replies - 7696 Views - Last Post: 24 July 2006 - 01:34 PM Rate Topic: -----

#1 ezywrap  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 24-July 06

Passing values in Datagrid

Posted 24 July 2006 - 09:13 AM

I was trying to pass two values. My previous login page I passed ID to Patient.aspx and queried an Access DB. On this page I use user=Request.QueryString("ID") in the Page_Load sub to get the valued passed.

To direct to record.aspx I need to pass user and PatientID inorder to get the correct info from the DB.

<asp:HyperLinkColumn
Text="ok"
DataNavigateUrlField="Patient"
DataNavigateUrlFormatString="Record.aspx?UserID="&<%user%>&"&PatientID={0}"

/>

This doesn't work but when I hard code UserID with 1 then it works.

<asp:HyperLinkColumn
Text="ok"
DataNavigateUrlField="Patient"
DataNavigateUrlFormatString="Record.aspx?UserID=1&PatientID={0}"

/>

How can I pass user to DataNavigateUrlFormatString?
If there is a better way I'm open for suggestions.

Thank You

Is This A Good Question/Topic? 0
  • +

Replies To: Passing values in Datagrid

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Passing values in Datagrid

Posted 24 July 2006 - 11:02 AM

Try
DataNavigateUrlFormatString="Record.aspx?UserID="&<%=user%>&"&PatientID={0}"


or
DataNavigateUrlFormatString="Record.aspx?UserID="<%=user%>"&PatientID={0}"


Was This Post Helpful? 0
  • +
  • -

#3 ezywrap  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 24-July 06

Re: Passing values in Datagrid

Posted 24 July 2006 - 12:05 PM

Thanks for the response. Unfortunatlly neither worked. This is the error I get.

Literal content ('" DataNavigateUrlField="Patient" DataNavigateUrlFormatString="Record.aspx?UserID="') is not allowed within a 'System.Web.UI.WebControls.HyperLinkColumn'.

I tried <%redirect.write(user)%> outside the datgrid and the value printed correctly.

In the error it wont pick up the value of user.

Any suggestions.

Thanks
Was This Post Helpful? 0
  • +
  • -

#4 ezywrap  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 24-July 06

Re: Passing values in Datagrid

Posted 24 July 2006 - 01:34 PM

I changed the way I'm passing values. Here is the code that works. Thanks for your reply.

Sub DataRecords(s As Object, e As CommandEventArgs)

Dim strID as String
Dim patient as string

user=Request.QueryString("ID")

patient = e.CommandArgument.ToString()

Response.Redirect("Record.aspx?UserID="& user &"&PatientID=" & patient)

End Sub


<asp:templatecolumn>
<ItemTemplate>
<asp:imagebutton id="btnRecord" ImageUrl="view2.gif" Runat="Server"
OnCommand="DataRecords"
CommandArgument='<%# DataBinder.Eval(Container.DataItem, "Patient") %>' TEXT="Record" />
</ItemTemplate>
</ASP:templatecolumn>
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1