Results 1 to 2 of 2

Thread: Update grid view using query string

  1. #1
    MorganCooper is offline Senior Member
    Join Date
    Dec 2009
    Posts
    233
    Rep Power
    3

    Default Update grid view using query string

    Hi. I am working on one live project where I use asp.net as front end and MS-access as back end. I have one gridview in my form and need to update it using the querystring. What steps will be needed to do this. If u know inform me. Thanks in advanced.

  2. #2
    BellWard is offline Senior Member
    Join Date
    Dec 2009
    Posts
    236
    Rep Power
    3

    Default

    We should set DataNavigateUrlFields and DataNavigateUrlFormatString
    Properties of hyperlink in gridview to pass the row data
    HTML markup of the page look like

    Code:
    <asp:GridView ID="GridView1" runat="server" 
                  AutoGenerateColumns="False" 
                  DataSourceID="SqlDataSource1">
    <Columns>
    <asp:HyperLinkField DataNavigateUrlFields="ID,Name,Location" 
    DataNavigateUrlFormatString=
    "test.aspx?id={0}&name={1}&loc={2}" 
    Text="Transfer values to other page" />
    <asp:BoundField DataField="ID" HeaderText="ID" 
                    SortExpression="ID" />
    <asp:BoundField DataField="Name" HeaderText="Name" 
                    SortExpression="Name" />
    <asp:BoundField DataField="Location" HeaderText="Location" 
                    SortExpression="Location" />
    </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
    SelectCommand="SELECT [ID], [Name], [Location] FROM [Details]">
    </asp:SqlDataSource>
    Now write code mentioned below to get back values on test.aspx page

    Code:
    protected void Page_Load(object sender, EventArgs e)
    {
     string strID = Request.QueryString["id"];
     string strName = Request.QueryString["name"];
     string strLocation = Request.QueryString["loc"];
     lblID.Text = strID;
     lblName.Text = strName;
     lblLocation.Text = strLocation;
    }

Similar Threads

  1. Display Grid View without using Ajax
    By ThompsonHarris in forum Graphic & Displays
    Replies: 2
    Last Post: 07-09-2010, 01:55 PM
  2. query dependent on another query
    By Davisricky in forum Programming
    Replies: 2
    Last Post: 02-02-2010, 05:38 PM
  3. I cannot update my pc view
    By bunnut78 in forum Windows Vista
    Replies: 1
    Last Post: 04-20-2009, 07:36 AM
  4. Use a grid for layout
    By eirn.wonal in forum Web. 2.0
    Replies: 0
    Last Post: 06-26-2008, 12:50 PM
  5. Pin Grid Array
    By vandana43 in forum Processors
    Replies: 0
    Last Post: 03-19-2008, 11:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
SEO by SubmitEdge

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48