TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sean
NA
4
0
Datagrid populated through textbox date range?
May 11 2010 2:37 PM
I have a datagrid that I want to be populated by two text boxes based on the dates in the textboxes. At this point i cant get my sql string to read the text boxes and fill the datagrid. I can't get this to work, can someone please help, thanks in advance!!
Here's my connection to the database.
Sub Page_Load(sender as Object, e as EventArgs)
'BindData()
End Sub
'Sub BindData()
Public Sub Submit_Click(ByVal sender As Object, ByVal e As System.EventArgs)
'1. Create a connection
Dim strTxt as String
Dim conn as SQLconnection
Dim da as New SQLdataAdapter
Dim ds as New DataSet()
Dim cmd as SQLcommand
Dim newListItem1 as new ListItem()
Dim submit AS button
Dim beginDate As date
Dim endDate As Date
'Dim txtBeginDate As textbox
'Dim txtEndDate As textbox
txtBeginDate.text = beginDate
txtEndDate.text = endDate
conn = New SQLconnection("server=xxxxx; database=xxxxx; uid=xxxxx; pwd=xxxxx")
strTxt = "SELECT ID, MRN, Name, CheckInDate, Dept, Prov, DX1, DX1Desc, CPT1, CPT1Desc FROM OPPE_Clinic WHERE CheckInDate >= '"& beginDate & "' and CheckInDate <= '" & endDate & "' "
cmd = New SQLcommand(strTxt, conn)
'2. Create the command object, passing in the SQL string
Dim myCommand as New SqlCommand(strTxt, conn)
Dim myAdapter as New SqlDataAdapter(myCommand)
'Dim ds as New DataSet()
myAdapter.Fill(ds)
'Set the datagrid's datasource to the datareader and databind
conn.Open()
PPROClinic.DataSource = ds
PPROClinic.DataBind()
One.text = FormatDateTime(beginDate,2)
CheckInDate = Two.text
End Sub
</script>
Below is my datagrid and text boxes.
<html>
<head>
<title>Chief's Corner - PPRO</title>
<meta http-equiv="Content-Type" content="text/html;">
</head>
<body style="margin:0">
<FORM METHOD=POST ACTION="" runat=server>
<table border=0 bgcolor="#F9F9F2" height=455 width=800>
<tr>
<td colspan=15 heigth=10 class="content">Begin Date: <asp:textbox ID="txtBeginDate" NAME="txtBeginDate" runat="server" class="content" /> End Date: <asp:textbox id="txtEndDate" NAME="txtEndDate" runat="server" class="content" /> <asp:Button id="submit" runat="server" Text="Submit" OnClick="Submit_Click"></asp:Button></td>
</tr>
<tr>
<td>
Date 1: <asp:Label id="One" runat=server /><br>
Date 2: <asp:Label id="Two" runat=server />
</td>
</tr>
<tr>
<td
><asp:datagrid id="PPROClinic" runat="server" class="content" />
<columns>
<asp:BoundColumn datafield="ID" headertext="ID" ItemStyle-Width="5%" />
<asp:BoundColumn datafield="MRN" headertext="MRN" ItemStyle-Width="5%" />
<asp:BoundColumn datafield="Name" headertext="Name" />
<asp:BoundColumn datafield="CheckInDate" DataFormatString="{0:d}" headertext="Check In Date" ItemStyle-Width="10%" />
<asp:BoundColumn datafield="Dept" headertext="Dept" ItemStyle-Width="8%" />
<asp:BoundColumn datafield="Prov" headertext="Provider" ItemStyle-Width="18%" />
<asp:BoundColumn datafield="DX1" headertext="DX1" />
<asp:BoundColumn datafield="Dx1Desc" headertext="Dx1Desc" ItemStyle-Width="15%" />
<asp:BoundColumn datafield="CPT1" headertext="CPT1" />
<asp:BoundColumn datafield="CPT1Desc" headertext="CPT1Desc" ItemStyle-Width="12%" />
</columns>
</asp:DataGrid>
</td>
</tr>
</table>
</FORM>
Reply
Answers (
0
)
Ask : How to connect AspxGridView to SqlServer2005
Efficiently obtain recursive folder information