Solved

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

Posted on 2014-09-24
4
128 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
TFS 2015 Access denied. 1 34
Consume a webservice via VB in Visual Studio 2015 3 42
c#, case, if 4 37
Read top line from CSV file 14 57
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
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…

739 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