Need some help with HyperLinkColumn!

  • Thread starter Thread starter Morten
  • Start date Start date
M

Morten

Hi.

After a while I finaly discovered how to use HyperLinkColumns.
What I can't find is how to send mote than one "value" like
page.aspx?id1&id2!!!

<asp:HyperLinkColumn DataNavigateUrlField="InvoNo"
DataNavigateUrlFormatString="Invo.aspx?Id={0}" DataTextField="InvoNo"
HeaderText="Invo No.">
<HeaderStyle HorizontalAlign="Left"></HeaderStyle>
<ItemStyle HorizontalAlign="Left"></ItemStyle>
</asp:HyperLinkColumn>

I also need to send: ID2=Request.QueryString("custno")
??
Invo.aspx?Id={0}&ID2=Request.QueryString("custno")


Thanks...

Morten
 
Hi Morten,

Unfortunately, you can't use more than one column as a data source for an
HyperLinkColumn.

However, if the object that you're binding to your DataGrid is a DataTable,
there's a trick: you can add a new computed column to the DataTable, and
bind this column to your HyperLinkColumn.

In your ASPX, write:
<asp:HyperLinkColumn DataNavigateUrlField="InvoNo"
DataNavigateUrlFormatString="Invo.aspx?{0}" DataTextField="Computed"
HeaderText="Invo No.">

and in your CodeBehind, use:
DataSet ds = new DataSet();

sqlDataAdapter2.Fill(ds);

DataTable t = ds.Tables[0];

DataColumn dc = new DataColumn("Computed");

dc.Expression="Id=' + InvoNo + '&id2="+ Request.QueryString("custno") + "'";

t.Columns.Add(dc);

DataGrid1.DataSource=ds;

DataGrid1.DataBind();
 
Thanks AW.

Could You please help me a bit more.

My datagrid are filled like this.

Dim aOpenPost As New OleDb.OleDbDataAdapter("SELECT InvoNo, Dt,
Am, CustNo FROM CustTr WHERE (CustNo = '" & AcNo & "' " & tmpDt & ")", cnn)
Dim dsOpenPost As DataSet = New DataSet()
aOpenPost.Fill(dsOpenPost, "CustTr")
grdOpenPost.DataSource = dsOpenPost
grdOpenPost.DataBind()


:) Morten
 
After a tortal 'Read-down' og my pages and code I have reconsidered and done
some redisign and found that Request.QueryString("custno") belongs in a
session variable.

No more agony.

Thank.
 
Back
Top