如何将值从gridview的链接按钮传递到另一页. [英] how to pass value from gridview's link button to another page..?

查看:256
本文介绍了如何将值从gridview的链接按钮传递到另一页.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从gridview的链接按钮传递值,然后重定向到另一页.

How to pass a value from gridview''s link button, and redirect to another page.

推荐答案

您好,

让我告诉您要遵循的步骤

首先要像写数据控制和填充方法这样的基础知识.

在数据控件中,您必须放置类似以下的代码.

Hi,

let me tell you steps to follow

First basics are first like write datacontrol and fill methods.

in the datacontrol you''ve to places code something like this.

<a href="nextpage.aspx?id=<%#Eval("id")%>">Update</a>




然后在下一页中,您将基于该查询字符串填充第二个数据控件




And then In nextpage you''ve to fill your second datacontrol with based on that querystring

 if(Request.QueryString["id"]!=null)
{
   datacontrol.datasource=getDataByID(request.QueryString["id"].toString());
   datacontrol.databind();
}



之后,您必须在更新"按钮中编写更新代码.

为此尝试您自己的代码

最好的



After that you''ve to write update code in update button.

Try your own code for this

All the Best


在网格视图的链接按钮中,

您必须像这样设置链接按钮的回发网址属性

In your grid view''s link button,

you have to set your link button''s postback url property like this

<asp:linkbutton id="lnkEdit" postbackurl="<%# " text="Edit Courses" runat="server" xmlns:asp="#unknown"></asp:linkbutton>



在Eval中传递您自己的文件,通过该文件您可以选择其他形式的数据.

在编辑页面中,您需要检查一下..



in Eval Pass your own filed through which you want to select data on other form.

in edit page you need to check for this..

string id = Request.QueryString["ID"].ToString();

if(id != "" or id != null)
{
    //do your code for what you whant that id.
}



取得ID后,您可以使用更新查询中的where原因在db中编辑该值.



after getting id you can edit that value in db using where cause inside your update query..


这篇关于如何将值从gridview的链接按钮传递到另一页.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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