[REPOST]从gridview控件导航到另一个页面? [英] [REPOST]navigation from gridview control to another page?

查看:96
本文介绍了[REPOST]从gridview控件导航到另一个页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,



gridview包含列:id,image,title,location

行:5



一次点击第一行标题(电脑)

此链接转到computer.aspx



2nd行标题(会计)

此链接转至accountant.aspx



第3行标题(笔记本电脑)

这个链接转到laptop.aspx



第4行标题(相机)

此链接转到camera.aspx



第5行标题(手机)

此链接转至mobile.aspx



此链接导航是否有可能



请回复我



可能:如何



请回复我任何逻辑或示例网站或网址路径



或这里导航目的gridview或其他控件使用什么控件

请回复我

Dear All,

gridview contain columns: id, image, title,location
rows: 5

once click first row title(computer)
this link go to computer.aspx

2nd row title(Accountant)
this link go to accountant.aspx

3rd row title(laptop)
this link go to laptop.aspx

4th row title(camera)
this link go to camera.aspx

5th row title(mobile)
this link go to mobile.aspx

this link navigation is possible or not

please reply me

possible : how

please reply me any logic or examples sites or url paths

or here navigation purpose gridview or another control what control are use
please reply me

推荐答案

使用 RowCommand 事件这个:



试试这个:

Use RowCommand Event for this:

Try this:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
  {
    GridViewRow row = (GridViewRow)((LinkButton)e.CommandSource).NamingContainer;
          int rowIndex = row.RowIndex;

          if (rowIndex == 0)
          {
          Response.Redirect("computer.aspx");
          }
          else if (rowIndex == 1)
          {
          Response.Redirect("accountant.aspx");
          }
         /// and so on
 }





并阅读:

http://msdn.microsoft.com/en-us/library/system.web .ui.webcontrols.gridview.rowcommand%28v = vs.110%29.aspx [ ^ ]


参考



[ ^ ]


在Gridview中使用超链接字段



use hyperlink field in Gridview

<asp:gridview id="OrdersGridView"
       datasourceid="OrdersSqlDataSource"
       autogeneratecolumns="false"
       runat="server">

       <columns>

         <asp:boundfield datafield="ID"
           headertext="Order ID"/>
         <asp:boundfield datafield="title"
           headertext="title "/>
  <asp:boundfield datafield="location"
           headertext="Location"/>
         <asp:hyperlinkfield datatextfield="Computer"
           datatextformatstring="{0:c}"
           datanavigateurlfields="ProductID"
           datanavigateurlformatstring="~\Computer.aspx?"
           headertext="Price"
           target="_blank" />
       

       </columns>

     </asp:gridview>


这篇关于[REPOST]从gridview控件导航到另一个页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆