Solved

how do I get gridview to only show up when I click a button

Posted on 2014-09-24
4
124 Views
Last Modified: 2014-09-26
right now I have a asp:gridview in my html code and the datsource also in the html code.
the gridview calls the datasource and the grid shows up when the page loads.
but I need to fill the gridview with only a particular information connected with a textbox that has a soc. sec. number.  So the connection string would have to be in the on_click of a submit button.
example: web page opens with instructions to type in your soc. sec. number
                  click the submit button and the gridview will pop up with every day of the month for entering hours worked.
so if the gridview is a html tag how do I get it to delay till the textbox has been successfully filled?

thanks
gary
0
Comment
Question by:javagair
  • 3
4 Comments
 

Author Comment

by:javagair
ID: 40342707
attached is my code
gridview  no longer shows up on load.

added a parameter to the asp:datasource----not sure it is right

table is filled with the correct info, but the grid does not show up.
when I click the fill table button it goes to the databind statement at the bottom of filltable function but no table.

datasource is at the bottom of html code.

It is like even though there is data in table I'm not calling the right query info.

thanks
gary
0
 

Author Comment

by:javagair
ID: 40342711
would be nice to actually attach file
C--Users-garys-Downloads-ParameterProble
0
 
LVL 14

Accepted Solution

by:
dejaanbu earned 500 total points
ID: 40343311
I didnt check your full code. though, my suggestion is:

to pass ID parameter to SqlDatasource2, you have to do that in SQDatasource_Selecting event, just like
Protected Sub SqlDataSource2_Selecting(sender As Object, e As SqlDataSourceSelectingEventArgs)
    e.Command.Parameters("@IDs").Value = HERE GIVE YOUR IDs 
End Sub

Open in new window

AND, in your button click, just call CustomersGridView.DataBind()
no need for this line: CustomersGridView.DataSource = SqlDataSource2
0
 

Author Comment

by:javagair
ID: 40346504
first I abandoned the connection to sql that I made through the studio and created my own.  This code fills the gridview.

dejaanbu

I have never liked letting the studio connect to a database.  Your comments lead to some thought about how this works.

thanks

gary
 sqldateinfo = "Select WorkDate, Startday, StartTime, Endtime, StartLunch, EndLunch, PtoDetail, PtoPaid, PtoUnPaid, CompanyPto, CompanyPtoPAID, SymitarCode from EmployeeAccuminfo where (WORKDATE >=  '" & dateString & "' AND WORKDATE <= '" & datestring2 & "') and EMPLOYEEID = '" & Dst.Tables("Dsthireinfo").Rows(0).Item(0).ToString() & "'   ORDER BY ID ASC "
       
        Dim adapter5 As SqlDataAdapter = New SqlDataAdapter(sqldateinfo, Connection)
        Connection.Open()
        adapter5.Fill(Dst, "Dstdateinfo")
        Connection.Close()
        If Dst.Tables("Dstdateinfo") Is Nothing OrElse Dst.Tables("Dstdateinfo").Rows.Count = 0 Then
        Else
           
            CustomersGridView.DataSource = Dst.Tables("DstDateinfo")
            CustomersGridView.DataBind()
           
        End If
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question