如何将值传递给重定向的WebForm [英] how to pass value's to redirected WebForm
本文介绍了如何将值传递给重定向的WebForm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的Web窗体中,我有三个下拉列,一个标签,一个添加按钮和一个gridview.
在我的gridview上,我有一个超链接列.
点击该超链接列后,我必须重定向到下一个Web表单,该行的值应为4个标签上所述列的所有4个值.
如何在c#中实现它
请帮忙.
谢谢
Hi,
In my Web Form I have three drop down column , one label, one add button and a gridview .
On my gridview I have a hyperlink column.
On clicking that hyperlink column I have to redirected to next web form with value of that row’s all 4 above said column on 4 label''s .
How this will be implement in c#
Please Help.
Thanks
推荐答案
请参考以下代码
refer the following code
<asp:GridView ID="grvTest" runat="server" AutoGenerateColumns="false"
onrowcommand="grvTest_RowCommand">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lnkTest" runat="server" Text="Move" CommandName="Move"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
protected void grvTest_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Move")
{
GridViewRow row=(GridViewRow)((LinkButton)e.CommandSource).NamingContainer;
string name = row.Cells[0].Text;
Response.Redirect("Page2.aspx?name=" + name);
}
}
收集所有网格单元格值并按上面给出的形式形成url
collect all grid cell values and form the url as given above
这里是一个示例,您可以通过查询字符串将值传递给其他Webform
Here''s an example for you to pass the value to other webform through query string
<asp:TemplateField HeaderText="Document ID" HeaderStyle-CssClass="gridheaderleft"
ItemStyle-CssClass="boundfield" HeaderStyle-Width="100px">
<ItemTemplate>
<asp:HyperLink ID="hyperDocketDetails" Text='<%# bind("ClientDocumentIdentifier") %>'
runat="server" NavigateUrl='<%# "DocumentDetails.aspx?id="+ DataBinder.Eval(Container.DataItem,"ID") +"&moduleid="+ Request["moduleid"] + "&retURL=" + HttpUtility.UrlEncode(Request.Path + "?" + Request.QueryString) %>' />
<asp:Label ID="lblDocket" Text='<%# bind("ClientDocumentIdentifier") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
希望对您有帮助
Hope it helps
您好,
首先尝试找到GridViewRow(使用LinkButton跟踪单击的行).
然后使用GridView.Rows [index] .FindControl("ControlID")找到所有所需的控件.
将控件投放到适当的样式中,例如"DropDown","Label"等...
然后使用Response.Redirect(url),您可以根据需要进行重定向.
问候,
达摩什
Hi,
First of all try to locate GridViewRow(Track which row is clicked using LinkButton).
Then find all the desired control using GridView.Rows[index].FindControl("ControlID").
Cast control into appropriate tyle like "DropDown","Label" etc...
then using Response.Redirect(url), you can redirect as per your requirement.
Regards,
Dharmesh
这篇关于如何将值传递给重定向的WebForm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文