zoukankan      html  css  js  c++  java
  • DataGrid模版列超级链接列传递参数问题总结(多个参数传递)

    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:

    <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="购买">
    <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=="栏目名称">
     <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
    <asp:TemplateColumn HeaderText="标题">
    <HeaderStyle Width="14%"></HeaderStyle>
              <ItemTemplate>
        <a href=content.aspx?postid=(<%#DataBinder.Eval(Container.DataItem,"postid")%>)'>显示</a>
              </ItemTemplate>
    </asp:TemplateColumn>

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

    a.
    <asp:HyperLinkColumn DataTextField="ffff" HeaderText="fff" NavigateUrl="a.aspx?x=<%# DataBinder.Eval(Container.DataItem, "字段名1")%>&s=<%# DataBinder.Eval(Container.DataItem, "字段名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.

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

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

    6、此方法未经验证:

    <%
    string Window;

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

    <frame src="left_tree_list_map.aspx?dm_tree=101&Window=<%=Window%>" name="leftFrame" scrolling="auto">

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

  • 相关阅读:
    想自己创业想好了项目,但是没有资金怎么办?
    如果创业失败负债了,你选择先回去工作还债还是借贷继续创业?
    创业期间,应该怎么样坚持下去?如何从容面对困难?
    为什么在一线上班的员工比坐办公室的人更容易创业?
    四十多岁的男人还适合重新创业吗?
    未来10年什么行业发展比较好?
    假如有三百多万存款,做什么稳健实体生意好?
    2元钱可以创造多大的价值?
    创业初期要找什么样的合作人?
    debug
  • 原文地址:https://www.cnblogs.com/adam/p/667080.html
Copyright © 2011-2022 走看看