Solved

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

Posted on 2014-09-24
4
117 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
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 …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now