Redirecting page will open perticular webpage based on passing parameter?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mandlaanilbabu
    New Member
    • Sep 2012
    • 11

    Redirecting page will open perticular webpage based on passing parameter?

    Your blog is very help full,
    I have one requirement like this
    I have a table CUSTOMER in that CUSTID,NAME,URL columns is thier
    CUSTID NAME URL
    1 asp www.asp.net
    2 weblog www.weblogs.asp .net
    3 google www.google.com

    My question is I opening perticular url based on CUSTID

    I am Passing parameter Like www.Example.com ?CUSTID=1 That

    corressponding URL data(Ex:www.asp .net) It will open directly in browser

    using asp.net........
    plz help me ...........
    Thank you,
    anil
  • robertkjr3d
    New Member
    • Feb 2008
    • 6

    #2
    There are many ways to do this... My 1st choice would be to use a GridView control. Then you set the DataSource of that gridview to be the DataTable of your Customer table.

    In the design view for the grid, you can select linkbutton or the more complicated templateview (if you want more control). http://www.asp.net/web-forms/tutoria...iew-control-cs

    Comment

    • mandlaanilbabu
      New Member
      • Sep 2012
      • 11

      #3
      Thank u?
      I am trying already gridview I am selecting gridview transfar that value next page?

      Send me your mail Id I will send my code
      Any free time is their customize mt code I am asking above question

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        If you have any code, please post it in the thread.

        Comment

        • mandlaanilbabu
          New Member
          • Sep 2012
          • 11

          #5
          WebForm1.aspx
          Code:
          <asp:GridView ID="GvDept" runat="server" AutoGenerateSelectButton="True" 
                  onselectedindexchanging="GvDept_SelectedIndexChanging"></asp:GridView>
          [U]WebForm.aspx.cs[/U]
          protected void Page_Load(object sender, EventArgs e)
              {
                  SqlConnection con = new SqlConnection(
                      @"Data Source=<removed>;Initial Catalog=<removed>;Persist Security Info=True;User ID=<removed>;Password=<removed>");
          
                  SqlDataAdapter da = new SqlDataAdapter("select * from redirecturl", con);
          
                  DataSet ds = new DataSet();
                  da.Fill(ds, "redirecturl");
                  GvDept.DataSource = ds.Tables["redirecturl"];
                  GvDept.DataBind();
                  GvDept.DataKeyNames = new string[] { "customerid" };
              }
              protected void GvDept_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
              {
                  GvDept.SelectedIndex = e.NewSelectedIndex;
          
                  string Dno = GvDept.SelectedValue.ToString();
          
                  
                  Response.Redirect("~/QueryStringParams2.Aspx?Dno="+Dno);
                  
              }
          [U]QueryStringParams2.Aspx[/U]
          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
          
          <html xmlns="http://www.w3.org/1999/xhtml">
          <head runat="server">
              <title></title>
          </head>
          <body>
              <form id="form1" runat="server">
              <div>
              <asp:GridView ID="GvEmp" runat="server" 
                  EmptyDataText="There Are No Employees In Selected Department" 
                      AutoGenerateColumns="false" Width="99px">
                  <Columns>
                  <asp:TemplateField HeaderText="Redirect URL">
                  <ItemTemplate>
                  <a href='<%#Eval("coupounurl") %>'><%#Eval("coupounurl")%></a>
                  </ItemTemplate>
                  </asp:TemplateField>
                  </Columns>
                  </asp:GridView>
                  <br />
              </div>
              </form>
          </body>
          </html>
          [U].cs[/U]
          protected void Page_Load(object sender, EventArgs e)
              {
                  string Dno = Request.QueryString["Dno"];
                  //string strEmpId = Request.QueryString["strEmpId"];
                  SqlConnection con = new SqlConnection(
                      @"Data Source=<removed>;Initial Catalog=<removed>;Persist Security Info=True;User ID=<removed>;Password=<removed>");
          
                  SqlCommand cmd = new SqlCommand("select coupounurl from redirecturl where customerid=" + Dno, con);
          
                  con.Open();
                  SqlDataReader dr = cmd.ExecuteReader();
                  GvEmp.DataSource = dr;
                  GvEmp.DataBind();
                  con.Close();
          }
          Last edited by Rabbit; Sep 25 '12, 03:25 PM. Reason: Sensitive info removed. Please use code tags when psoting code.

          Comment

          • jdstankosky
            New Member
            • Sep 2012
            • 30

            #6
            You may wish to censor your password...

            Comment

            • Rabbit
              Recognized Expert MVP
              • Jan 2007
              • 12517

              #7
              I have removed the sensitive information. Please use code tags when posting code.

              It looks like you're already outputting a url, why would you need an additional redirect?

              Comment

              • mandlaanilbabu
                New Member
                • Sep 2012
                • 11

                #8
                Thank you,
                my question is I am selecting First page gridview value based on that I want to open Browser that url,

                Comment

                • mandlaanilbabu
                  New Member
                  • Sep 2012
                  • 11

                  #9
                  Not open next page,directly open browser,
                  after thatmy url look like something?CUSTI D=1

                  After iam cheanging qs values2,3.....b ased on that values directly open in broser not next page

                  Comment

                  • Rabbit
                    Recognized Expert MVP
                    • Jan 2007
                    • 12517

                    #10
                    I have no idea what you just said.

                    Comment

                    • mandlaanilbabu
                      New Member
                      • Sep 2012
                      • 11

                      #11
                      Understand my question completely

                      Comment

                      • Rabbit
                        Recognized Expert MVP
                        • Jan 2007
                        • 12517

                        #12
                        The problem is that I don't understand what you're trying to say. Telling me to understand something doesn't help me to decipher what you're trying to say.

                        Comment

                        • jdstankosky
                          New Member
                          • Sep 2012
                          • 30

                          #13
                          Understand his question completely.


                          Trololol

                          Comment

                          • mandlaanilbabu
                            New Member
                            • Sep 2012
                            • 11

                            #14
                            any body help me the above question

                            Comment

                            • jdstankosky
                              New Member
                              • Sep 2012
                              • 30

                              #15
                              From what I gather, there is a database table somewhere that has at least 3 columns: custid, sitedesc, siteurl.

                              Using asp.net (of which I know nothing about), he would like to open a NEW browser with the siteurl that matches the row with a particular custid, based on a GET variable in the URL?

                              Comment

                              Working...