DataGrid template column hyperlink column passing parameter problem summary (multiple parameter passing)

Source: Internet
Author: User

1. There is a small error. The general method is correct. Use a Java Script.

Navigateurl = "javascript: var win = Window. Open ('<% #" ksmd. aspx? Kcbh = "+ databinder. eval (container, "dataitem. course No. ") +" & ksrq = "+ databinder. eval (container, "dataitem. exam date ") %> ','', 'height = 250, width = 700, Top = 250, Left = 150, toolbar = No, menubar = No, crollbars = No, resizable = No, location = No, status = no ')"
2,

The DataGrid's hyperlinkcolumn column is great to have a column with an hyperlink that points to an URL with a parameter whose value is taken from the data source, but what if you need to build the target URL with more than one parameter taken from the data source? In this case you can use a template column as follows:

<Templatecolumn>
<Itemtemplate>
<Asp: hyperlink runat = "server" navigateurl = '<% # "details. aspx? Employeeid = "& container. dataitem (" ID ") &" & employeename = "& container. dataitem (" firstname ") %> '/>
</Itemtemplate>
</Templatecolumn>

Instead of doing the String concatenation yourself you can use the buildurlwithquerystring function, which must be declared with public/protected visibility in the code-behind, as follows:

<Templatecolumn>
<Itemtemplate>
<Asp: hyperlink runat = "server" navigateurl = '<% #_
Buildurlwithquerystring ("details. aspx", "employeeid", container. dataitem ("ID"), "employeename", container. dataitem ("firstname") %> '/>
</Itemtemplate>
</Templatecolumn>

Http://java.mblogger.cn/brian_jin/posts/2792.aspx

<Asp: templatecolumn headertext = "buy">
<Itemtemplate>
<Asp: hyperlink id = hyperlink1 runat = "server"
TEXT = '<% # databinder. eval (container, "dataitem. dinggou") %>'
Navigateurl = '<% # "../gouwu/gouwu_ls.aspx? Commoditytype = "&
Databinder. eval (container, "dataitem. commoditytype ")
& "& Commodityname =" & databinder. eval (container, "dataitem. commodityname") %> '/>
</Itemtemplate>
</ASP: templatecolumn>

3,

<Asp: templatecolumn headertext = "topic name">
<Itemtemplate>
<Asp: hyperlink text = '<% # databinder. eval (container, "dataitem. ica_name") %> 'navigateurl =' <% # "newsdetail. aspx? Id = "+ databinder. eval (container, "dataitem. ica_id ") +" & name = "+ databinder. eval (container, "dataitem. ica_name ") %> 'runat =" server "/>
</Itemtemplate>
</ASP: templatecolumn>

4. href for fixed text display
<Asp: templatecolumn headertext = "title">
<Headerstyle width = "14%" type = "codeph" text = "/codeph"> <Itemtemplate>
<A href = content. aspx? Postid = (<% # databinder. eval (container. dataitem, "postid") %>) '> display </a>
</Itemtemplate>
</ASP: templatecolumn>

5. How can I bind more than one field to pass multiple parameters in the DataGrid hyperlink column (hyperlinkcolum?

A.
<Asp: hyperlinkcolumn datatextfield = "ffff" headertext = "fff" navigateurl = "A. aspx? X = <% # databinder. eval (container. dataitem, "field name 1") %> & s = <% # databinder. eval (container. dataitem, "field name 2") %> "> </ASP: hyperlinkcolumn

B.
Page. response. Redirect ("repair_fitting_edit.aspx? Repair_name = "+ mydatagrid. items [E. item. itemindex]. cells [0]. text + "& fitting_get_day =" + mydatagrid. items [E. item. itemindex]. cells [1]. text + "& fitting_no =" + mydatagrid. items [E. item. itemindex]. cells [2]. text );

C.

First, convert the DataGrid to the template column, and then fill in the following content in the "attributes"-> "binding"-> text of hyperlink in the template column:

Databinder. eval (container. dataitem, "field name 1") + databinder. eval (container. dataitem, "field name 2 ")

 

6. This method has not been verified:

<%
String window;

Window = request. querystring ["window"];
%>

<Frame src = "left_tree_list_map.aspx? Dm_tree = 101 & window = <% = Window %> "name =" leftframe "scrolling =" Auto ">

 

7. All of the above are directly written in HTML on the page. This method is used to directly write the. CS file.

String connstr = @ "Integrated Security = sspi; user id = sa; initial catalog = northwind; Data Source = myserver \ netsdk ";

Sqlconnection CNN = new sqlconnection (connstr );

Sqldataadapter da = new sqldataadapter ("select * from employees", CNN );

Dataset DS = new dataset ();

Da. Fill (DS, "employees ");

Itemplate temp = page. loadtemplate ("webusercontrol1.ascx ");

Templatecolumn Tc = new templatecolumn ();

TC. headertext = "last name ";

TC. itemtemplate = temp;

Datagrid1.columns. Add (TC );

Datagrid1.datasource = Ds;

Datagrid1.datamember = "employees ";

Datagrid1.databind ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.