Please help my webform label controls remains empty yet i have selected a record to populate it please help
<form id="form1" runat="server">
<div>
<table class="auto-style1">
<tr>
<td class="auto-style2">AccNo</td>
<td class="auto-style3" colspan="4">
<asp:TextBox ID="Acnos" runat="server"></asp:TextBox>
</td>
<td class="auto-style4" colspan="3">
<asp:Label ID="BookName" runat="server"></asp:Label>
</td>
<td class="auto-style6">
<asp:Label ID="Author" runat="server"></asp:Label>
</td>
<td class="auto-style6">EntryCode</td>
<td colspan="6" class="auto-style6">
<asp:Label ID="Entrycode" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style2"> </td>
<td colspan="12" class="auto-style6"> </td>
<td class="auto-style6"> </td>
<td class="auto-style6"> </td>
<td class="auto-style6"> </td>
</tr>
<tr>
<td colspan="3" class="auto-style6">
<asp:Button ID="Button1" runat="server" Text="TRANSFER ACCNO" />
</td>
<td colspan="4" class="auto-style6"> </td>
<td class="auto-style7">
<asp:Label ID="TbookName" runat="server"></asp:Label>
</td>
<td colspan="3" class="auto-style6">Transfer To Entrycode:</td>
<td colspan="5" class="auto-style6">
<asp:Label ID="Tentrycode" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td colspan="2" class="auto-style6"> </td>
<td colspan="4" class="auto-style6"> </td>
<td colspan="2" class="auto-style6">
<asp:Label ID="CNo" runat="server"></asp:Label>
</td>
<td colspan="4" class="auto-style6">Transfer To Author:</td>
<td colspan="4" class="auto-style6">
<asp:Label ID="TAuthor" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td colspan="4" class="auto-style6"> </td>
<td colspan="2" class="auto-style6">
<asp:TextBox ID="bkname" runat="server"></asp:TextBox>
</td>
<td colspan="2" class="auto-style6">Subject Transfer</td>
<td colspan="8" class="auto-style6">
<asp:Label ID="Tsubject" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td colspan="16">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="Transferlist" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:ButtonField CommandName="Editbook" Text="Select " HeaderText="Select" />
<asp:BoundField DataField="Callno" HeaderText="CallNo" />
<asp:BoundField DataField="BookName" HeaderText="BookName" />
<asp:BoundField DataField="author" HeaderText="Author" />
<asp:BoundField DataField="Subject" HeaderText="Subject" />
<asp:BoundField DataField="Edition" HeaderText="Edition" />
<asp:BoundField DataField="Entrycode" HeaderText="EntryCode" />
</Columns>
</asp:GridView>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</table>
</div>
</form>
Imports System.Data.SqlClient
Imports System.Data
Imports System.Collections
Public Class TransferAcno
Inherits System.Web.UI.Page
Dim conString As String = ConfigurationManager.ConnectionStrings("SLISConnectionString").ConnectionString
Dim time3, time2 As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
' BindGrid()
End If
End Sub
Protected Sub BindGrid()
Using con As New SqlConnection(conString)
Using cmd As New SqlCommand()
cmd.CommandText = "SELECT bookcode As Callno, Bookname, Author,category as Subject,class as Edition, autofield as Entrycode FROM stockkabojja"
cmd.Connection = con
' cmd.Parameters.AddWithValue("@autono", Entrycode.Text.Trim())
Dim dt As New DataTable()
Using sda As New SqlDataAdapter(cmd)
sda.Fill(dt)
If dt.Rows.Count > 0 Then
Transferlist.DataSource = dt
Transferlist.DataBind()
Transferlist.UseAccessibleHeader = True
Transferlist.FooterRow.TableSection = TableRowSection.TableFooter
Transferlist.HeaderRow.TableSection = TableRowSection.TableHeader
Else
Dim time23 As String = "No Records Loaded"
ScriptManager.RegisterStartupScript(Me, [GetType](), "showalert", "alert('" & time23 & "');", True)
' Transferlist.DataSource = Nothing
Transferlist.DataBind()
'Transferlist.Visible = False
Exit Sub
End If
End Using
End Using
End Using
End Sub
Protected Sub Acnos_TextChanged(sender As Object, e As EventArgs) Handles Acnos.TextChanged
simpledata2()
End Sub
Protected Sub simpledata2()
Dim B As String
B = IsNumeric(Acnos.Text)
If B = False Then
Dim time23 As String = "Strictly Use Numerical Values"
ScriptManager.RegisterStartupScript(Me, [GetType](), "showalert", "alert('" & time23 & "');", True)
Me.Acnos.Text = ""
Exit Sub
Else
Using Con As New SqlConnection(conString)
Con.Open()
Using Com2 As New SqlCommand("SELECT bookname, author,category,bookcode,autono FROM categorycodes WHERE bookcode = '" & Acnos.Text & "'", Con)
Using RDR2 = Com2.ExecuteReader()
If RDR2.HasRows Then
RDR2.Read()
time2 = RDR2.Item("author").ToString()
time3 = RDR2.Item("bookname").ToString()
Author.Text = RDR2.Item("author").ToString()
BookName.Text = RDR2.Item("bookname").ToString()
Entrycode.Text = RDR2.Item("autono").ToString()
' Author.Text = time2
BindGrid()
Else
Dim time23 As String = "Accession Code Does not Exist "
ScriptManager.RegisterStartupScript(Me, [GetType](), "showalert", "alert('" & time23 & "');", True)
Tentrycode.Text = ""
End If
Con.Close()
End Using
End Using
End Using
Tentrycode.Visible = True
' Transerbutton.Visible = True
' Label4.Visible = True
' Label3.Visible = True
End If
End Sub
Private Sub Transferlist_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles Transferlist.RowCommand
If e.CommandName = "Editbook" Then
Dim index As Integer = Convert.ToInt32(e.CommandArgument)
Dim row As GridViewRow = Transferlist.Rows(index)
Tentrycode.Text = row.Cells(6).Text
Dim hold As String = row.Cells(6).Text
Using Con As New SqlConnection(conString)
Con.Open()
Using Com2 As New SqlCommand("SELECT bookcode As Callno, Bookname, Author,category as Subject,class as Edition, autofield as Entrycode FROM stockkabojja WHERE autofield = '" & hold & "'", Con)
Using RDR2 = Com2.ExecuteReader()
If RDR2.HasRows Then
RDR2.Read()
time2 = RDR2.Item("author").ToString()
time3 = RDR2.Item("bookname").ToString()
TAuthor.Text = RDR2.Item("author").ToString()
TbookName.Text = RDR2.Item("bookname").ToString()
Tentrycode.Text = RDR2.Item("Entrycode").ToString()
Tsubject.Text = RDR2.Item("Subject").ToString()
bkname.Text = RDR2.Item("bookname").ToString()
' Author.Text = time2
' BindGrid()
' Else
' Dim time23 As String = "Accession Code Does not Exist "
' ScriptManager.RegisterStartupScript(Me, [GetType](), "showalert", "alert('" & time23 & "');", True)
' Tentrycode.Text = ""
End If
Con.Close()
End Using
End Using
End Using
' Acnos.Text = accno
' BindGrid()
Exit Sub
End If
End Sub
End Class