M
mike
I'm having a problem with binding my sqldatareader to my
datagrid in my asp .net page.
Below is my code in the page_load section of the code
behind page:
Dim oCon2 As SqlClient.SqlConnection = New
SqlClient.SqlConnection("data source=Test;initial
catalog=data1;password=;user id=sa;packet size=4096")
oCon2.Open()
Dim cmd As SqlClient.SqlCommand = New
SqlClient.SqlCommand("AwardCalendar2", oCon2)
cmd.CommandType = CommandType.StoredProcedure
Dim par As SqlClient.SqlParameter = New
SqlClient.SqlParameter("@Date", SqlDbType.DateTime)
par.Direction = ParameterDirection.Input
par.Value = strdate
cmd.Parameters.Add(par)
Dim sqlreader As SqlClient.SqlDataReader
sqlreader = cmd.ExecuteReader()
DataGrid1.DataSource = sqlreader
DataGrid1.DataBind()
sqlreader.Close()
oCon2 = Nothing
The datagrid in the aspx file is defined as follows:
<aspataGrid id="DataGrid1" style="Z-INDEX: 105; LEFT:
14px; POSITION: absolute; TOP: 146px" runat="server"
Height="178px" Width="532px" ForeColor="Black"
BackColor="#8080FF" BorderColor="Blue"></aspataGrid>
When I run the page it doesn't show the datagrid. I have
a querystring that specifies the date value entered.
datagrid in my asp .net page.
Below is my code in the page_load section of the code
behind page:
Dim oCon2 As SqlClient.SqlConnection = New
SqlClient.SqlConnection("data source=Test;initial
catalog=data1;password=;user id=sa;packet size=4096")
oCon2.Open()
Dim cmd As SqlClient.SqlCommand = New
SqlClient.SqlCommand("AwardCalendar2", oCon2)
cmd.CommandType = CommandType.StoredProcedure
Dim par As SqlClient.SqlParameter = New
SqlClient.SqlParameter("@Date", SqlDbType.DateTime)
par.Direction = ParameterDirection.Input
par.Value = strdate
cmd.Parameters.Add(par)
Dim sqlreader As SqlClient.SqlDataReader
sqlreader = cmd.ExecuteReader()
DataGrid1.DataSource = sqlreader
DataGrid1.DataBind()
sqlreader.Close()
oCon2 = Nothing
The datagrid in the aspx file is defined as follows:
<aspataGrid id="DataGrid1" style="Z-INDEX: 105; LEFT:
14px; POSITION: absolute; TOP: 146px" runat="server"
Height="178px" Width="532px" ForeColor="Black"
BackColor="#8080FF" BorderColor="Blue"></aspataGrid>
When I run the page it doesn't show the datagrid. I have
a querystring that specifies the date value entered.