Click here to Skip to main content
15,884,821 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Comments
Chandrashekar SK 23-Nov-12 6:19am    
Try if this works..
Session["Value1"] = gridView.Rows[e.RowIndex].Cells[1].Text;

and retrieve the value on the other page like.
String value1 = Session["Value1"].ToString();

refer the following code

XML
<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>



C#
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);
          }
        }


collect all grid cell values and form the url as given above
 
Share this answer
 
v2
Here's an example for you to pass the value to other webform through query string

XML
<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
 
Share this answer
 
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900