GridView Problems

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MarkTingson
    New Member
    • Nov 2007
    • 40

    #1

    GridView Problems

    Hi guys,

    Can you help me with my problem?

    I have 2 web forms, Home webform and Admin webform.
    Each webform has 1 gridview, grdHome and grdAdmin.

    I also have 1 table which has field1,field2,f ield3,field4,fi eld5,field6
    grdHome has 3 columns: field1, field2 & field3.
    grdAdmin has also 3 columns field4,field5,f ield6
    I have successfully created a hyperlink in grdHome's field1. It is hyperlinked in the Admin webform.

    What I want to do is:

    1.) when i click one record in field1, the grdAdmin in the Admin webform should only display the specific record from field 4,field 5 and field 6...


    Thanks,

    Please help me..
  • Shashi Sadasivan
    Recognized Expert Top Contributor
    • Aug 2007
    • 1435

    #2
    this is something to do with passing parameters and then querying the database and databinding the gridview to the data source.

    Where are you facing problems?

    Comment

    • MarkTingson
      New Member
      • Nov 2007
      • 40

      #3
      I really don't know how to do it.. I am only new in .ASP but im pretty familiar with VB script..can you show me some codes?and where to put it?

      Comment

      • Shashi Sadasivan
        Recognized Expert Top Contributor
        • Aug 2007
        • 1435

        #4
        How are you filling data into your grid view (especially for the admin)?

        What you would need is to refill the admin grid depending upon a certain value.
        So you would only need to modify your sql query a bit to accomodate that.

        Once you get that working you can use query strings, or session variable when moving to the admin page when the link is clicked.

        However im not sure how this is to be done if 2 browser windows are open and you want to effectively change the data in the second browser based on what you clicked in the first one

        Comment

        • MarkTingson
          New Member
          • Nov 2007
          • 40

          #5
          ok..

          my grdAdmin has no query.. i actually leave it blank because i am researching how to do it...

          what i need to do is when i click the hyperlink in grdHome, grdADmin must display the specific record that corresponds to what records i click..

          meaning to say, grdAdmin must display only 3 columns, with 1 row..

          so far, i have done nothing, but i am succesful creating a hyperlink in the gridview

          please help me..what i want is to display a specific record in my grdAdmin in the Admin webform..

          Thanks

          Comment

          • MarkTingson
            New Member
            • Nov 2007
            • 40

            #6
            How can i refill the admin depending upon a certain value?

            Comment

            • MarkTingson
              New Member
              • Nov 2007
              • 40

              #7
              How can i refill the admin gridview depending upon a certain value?

              Comment

              • Shashi Sadasivan
                Recognized Expert Top Contributor
                • Aug 2007
                • 1435

                #8
                Allright,
                Have you connected your application to the database?

                what database backend are you using

                you would need to build up a sql query like
                [CODE=sql]select field4,field5,f ield6 from my table where field1 = 'avalue';[/CODE]

                If you do not know how to connect your application to a database and query, i suggest you search the forum (and even howtos) and the internet too for this.

                Comment

                • MarkTingson
                  New Member
                  • Nov 2007
                  • 40

                  #9
                  Thanks,

                  I am using SQL Server 2005 as my database.. I already connected my grdHome to it..

                  I am successful populating the records in grdHome..

                  where will I put this SQL code? this is actually what i'm thinking of..

                  Does the 'avalue' means that it is equal to the record I clicked?

                  Comment

                  • MarkTingson
                    New Member
                    • Nov 2007
                    • 40

                    #10
                    This is my code:

                    <asp:GridView ID="grdHome" runat="server" AllowPaging="Tr ue" AllowSorting="T rue"
                    AutoGenerateCol umns="False" CellPadding="4" DataSourceID="S qlDataSource3" BackColor="Whit e" BorderColor="#C C9966" BorderStyle="No ne" BorderWidth="2p x" style="z-index: 100; left: 57px; position: absolute; top: 216px" OnSelectedIndex Changed="grdAdm in_SelectedInde xChanged" PageSize="5">
                    <FooterStyle BackColor="#FFF FCC" ForeColor="#330 099" />
                    <Columns>
                    <asp:HyperLinkF ield DataNavigateUrl Fields="Project _name"
                    HeaderText="Pro ject Name"
                    SortExpression= "Project_na me"
                    DataNavigateUrl FormatString="A dmin.aspx?id={0 }"
                    DataTextField=" Project_Name"

                    NavigateUrl="Ad min.aspx"/>
                    <asp:BoundFie ld DataField="Proj ect_manager" HeaderText="Pro ject Manager" SortExpression= "Project_manage r" />
                    <asp:BoundFie ld DataField="ITP_ status" HeaderText="Sta tus" SortExpression= "ITP_status " />
                    <asp:BoundFie ld DataField="Date _requested" HeaderText="Dat e Submitted" SortExpression= "Date_requested " />
                    </Columns>
                    <RowStyle BackColor="Whit e" ForeColor="#330 099" />
                    <SelectedRowSty le BackColor="#FFC C66" Font-Bold="True" ForeColor="#663 399" />
                    <PagerStyle BackColor="#FFF FCC" ForeColor="#330 099" HorizontalAlign ="Center" />
                    <HeaderStyle BackColor="#990 000" Font-Bold="True" ForeColor="#FFF FCC" />
                    </asp:GridView>

                    notice the hyperlink?it will be go to the Admin webform.. as of now my admin has gridview but it has no query.. where will i put the query?

                    Comment

                    • Shashi Sadasivan
                      Recognized Expert Top Contributor
                      • Aug 2007
                      • 1435

                      #11
                      Okay..
                      thanks for that piece of code.
                      Now as you said you are using SQL Server, hopefully you are using typed datasets (ie you would have dragged and dropped tables from SQL Server onto visual studio)
                      where the table is created you also have an adapter associated. Right click that and choose add new query.

                      this should bring you to a more sql familiar area and create a parametr for the field id that you are passing from your previous form

                      this will appear as a method within your tableAdapter method now

                      Once you are in Admin.aspx

                      run Request.QuerySt ring("id");
                      to retrive the value passed from the home grid. use this id to feed into the tabl;eAdapter method created.

                      Comment

                      • MarkTingson
                        New Member
                        • Nov 2007
                        • 40

                        #12
                        Thank you sir...

                        :-)

                        Comment

                        Working...