修改我的文档默认路径:DataGrid模版列超级链接列传递参数问题总结(多个参数传递) [和讯博客]

来源:百度文库 编辑:偶看新闻 时间:2024/05/09 08:07:15
DataGrid模版列超级链接列传递参数问题总结(多个参数传递)[原创 2005-08-20 15:58:33 ] 发表者: CAROLhzj   


1、存在小错误,总体方法是对的,使用java脚本

NavigateUrl="javascript:var win=window.open(‘<%# "ksmd.aspx?kcbh="+DataBinder.Eval(Container,"DataItem.课程编号")+"&ksrq="+DataBinder.Eval(Container,"DataItem.考试日期")%>‘,‘‘,‘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:


   
       ‘/>
   

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:


   
               BuildUrlWithQueryString("Details.aspx", "EmployeeID", Container.DataItem("ID"),"EmployeeName", Container.DataItem("FirstName")) %>‘ />
  

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



 Text=‘<%# DataBinder.Eval(Container, "DataItem.dinggou")%>‘
 NavigateUrl=‘<%# "../gouwu/gouwu_ls.aspx?commoditytype=" &
  DataBinder.Eval(Container, "DataItem.commoditytype")
  & "&commodityname=" & DataBinder.Eval(Container, "DataItem.commodityname")%>‘ />

3、


 
‘ NavigateUrl=‘<%# "newsdetail.aspx?id="+DataBinder.Eval(Container, "DataItem.ica_id")+"&name="+DataBinder.Eval(Container, "DataItem.ica_name") %>‘ runat="server"/>
 

4、固定的文字显示用href


         
    )‘>显示
         


5、DataGrid超级链接列(HyperLinkColum)中如何绑定一个以上字段,传递多个参数?

a.
&s=<%# DataBinder.Eval(Container.DataItem, "字段名2")%>">

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.

先将datagrid转换到模板列,然后在模板列中hyperlink的“属性”—> “绑定”-> text 内容里填写以下内容:

DataBinder.Eval(Container.DataItem, "字段名1") + DataBinder.Eval(Container.DataItem, "字段名2")

 

6、此方法未经验证:

<%
string Window;

Window = Request.QueryString["Window"];
%>

 

7、以上均为在页面中直接编写HTML实现,此种方法直接编写.cs文件

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();