Hello
I am receiving an error when trying to bind my gridview. It works fine when I set Autogenerate columns = TRUE
This code works fine at my job but now I'm trying to do my own site using GoDaddy
HTML:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="user"
runat="server"
Text='<%#Bind("userid")%>'
>
</asp:Label>
</ItemTemplate>
/asp:TemplateField>
</Columns>
</asp:GridView>
This is my server side code...
Sub GetData()
conn.ConnectionString = connectstr
Dim strSQL As String = "select userid from GG_HISTORY where userid='JSMITH' "
Dim Cmd As New SqlClient.SqlCommand
Cmd.Connection = conn
Cmd.CommandText = strSQL
Dim Sql_DA_Request As New SqlClient.SqlDataAdapter
Sql_DA_Request.SelectCommand = Cmd
conn.Open()
Dim Tbl_Request As New DataTable
Sql_DA_Request.Fill(Tbl_Request)
GridView1.DataSource = Tbl_Request
If Tbl_Request.Rows.Count > 0 Then
GridView1.DataBind()
End If
conn.Close()
End Sub
Any help is appreciated -
Thanks
Dave
I am receiving an error when trying to bind my gridview. It works fine when I set Autogenerate columns = TRUE
This code works fine at my job but now I'm trying to do my own site using GoDaddy
HTML:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="user"
runat="server"
Text='<%#Bind("userid")%>'
>
</asp:Label>
</ItemTemplate>
/asp:TemplateField>
</Columns>
</asp:GridView>
This is my server side code...
Sub GetData()
conn.ConnectionString = connectstr
Dim strSQL As String = "select userid from GG_HISTORY where userid='JSMITH' "
Dim Cmd As New SqlClient.SqlCommand
Cmd.Connection = conn
Cmd.CommandText = strSQL
Dim Sql_DA_Request As New SqlClient.SqlDataAdapter
Sql_DA_Request.SelectCommand = Cmd
conn.Open()
Dim Tbl_Request As New DataTable
Sql_DA_Request.Fill(Tbl_Request)
GridView1.DataSource = Tbl_Request
If Tbl_Request.Rows.Count > 0 Then
GridView1.DataBind()
End If
conn.Close()
End Sub
Any help is appreciated -
Thanks
Dave