Problem in saving value of a textbox into a variable

V

velu

I have a problem in saving value of textbox1 and RadioButtonList1 into a
variable so that i can insert a rec in the table.....following is the HTML
CODE

<asp:datagrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 8px; POSITION:
absolute; TOP: 8px" runat="server"
Width="500px" AutoGenerateColumns="False">
<AlternatingItemStyle Font-Size="Smaller"
Font-Names="Verdana,Arial,Helvetica,sans-serif"
BackColor="#E5E5E5"></AlternatingItemStyle>
<ItemStyle Font-Size="Smaller"
Font-Names="Verdana,Arial,Helvetica,sans-serif"
BackColor="#F2F2F2"></ItemStyle>
<HeaderStyle Font-Size="Smaller"
Font-Names="Verdana,Arial,Helvetica,sans-serif" Font-Bold="True"
HorizontalAlign="Center" ForeColor="#3D3DB6"
BackColor="#E8EBFD"></HeaderStyle>
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField="documentURL"
DataTextField="documentLabel" HeaderText="Developer
Guides"></asp:HyperLinkColumn>
<asp:BoundColumn DataField="documentFormat" ReadOnly="True"
HeaderText="Format"></asp:BoundColumn>
<asp:BoundColumn DataField="documentDate" ReadOnly="True"
HeaderText="Date"></asp:BoundColumn>
<asp:BoundColumn Visible="False" DataField="avgRating" ReadOnly="True"
HeaderText="Number_Rating"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Rating">
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle"></ItemStyle>
<ItemTemplate>
<asp:label id="lblStarRating" runat="server"></asp:label>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="RatingCount" ReadOnly="True" HeaderText="Rating
Count">
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle"></ItemStyle>
</asp:BoundColumn>
<asp:TemplateColumn HeaderText="Rate It">
<ItemTemplate>
<P>
<asp:LinkButton id="LinkButton1" runat="server"
CommandName="Open_panel">LinkButton</asp:LinkButton></P>
<P>
<asp:Label id="Label1" runat="server" Visible="False">You have already rated
this..!</asp:Label></P>
<asp:panel id="Panel1" runat="server" Width="168px" Visible="False"
Height="264px" BorderColor="#E0E0E0">
<P>
<asp:RadioButtonList id="RadioButtonList1" tabIndex="1" runat="server"
RepeatDirection="Horizontal" RepeatLayout="Flow">
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
<asp:ListItem Value="4">4</asp:ListItem>
<asp:ListItem Value="5">5</asp:ListItem>
</asp:RadioButtonList></P>
<P>
<asp:TextBox id="TextBox1" tabIndex="3" runat="server" Width="152px"
Height="145px"></asp:TextBox></P>
<P>
<asp:LinkButton id="LinkButton2" runat="server"
CommandName="rate_it">Submit</asp:LinkButton></P>
</asp:panel>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="documentID" HeaderText="document
ID"></asp:BoundColumn>
</Columns>
</asp:datagrid>

the ASP.NET CODE BELOW

Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
DataGrid1.ItemCommand

Select Case e.CommandName


Case "rate_it"

'If ((e.Item.ItemType <> ListItemType.Header) And (e.Item.ItemType <>
ListItemType.Footer)) Then
If Not Page.IsPostBack Then

Else

If (e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem) Then
DocumentID = Convert.ToInt32(e.Item.Cells(7).Text)

Dim rate As String
Dim RBL As RadioButtonList =
CType(e.Item.Cells(6).FindControl("RadioButtonList1"), RadioButtonList)
rate = Convert.ToString(RBL.SelectedValue)


Dim UserIP As String
UserIP = CStr(Request.UserHostAddress)

Dim comments As String
Dim TB As TextBox = CType(e.Item.Cells(6).FindControl("Textbox1"), TextBox)



Dim conPubs As SqlConnection
Dim cmdIns As SqlCommand
conPubs = New SqlConnection("server=BGLAMDJVELU;Database=Pubs;Integrated
security=sspi")
cmdIns = New SqlCommand("INSERT INTO tbl_rating (rating, ip, documentID,
usercomment) VALUES (" & rate & " ,'" & UserIP & "'," & DocumentID & ",'" &
comments & "');", conPubs)
conPubs.Open()
cmdIns.ExecuteReader()
conPubs.Close()
'bind the result.....
cmdSelect = New SqlCommand("select D.documentID, D.documentType,
D.documentLabel, D.documentURL, D.documentFormat, D.documentDate,
COALESCE(AVG(rating),0) AS avgRating, (COUNT(rating)) AS RatingCount from
tbl_documents as D left outer join tbl_Rating as R on R.documentID =
D.documentID group by D.documentID, D.documentLabel, D.documentType,
D.documentURL, D.documentFormat, D.documentDate", conPubs)

conPubs.Open()
DataGrid1.DataSource = cmdSelect.ExecuteReader()
DataGrid1.DataBind()
conPubs.Close()
End If

End If
End Select

its nearly a week i am wonder what went wrong...pls help i wonder is there
any thing wrong with HTML code...?

as of now i get only "" empty value for this in runtime trace....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top