Logo 
Search:

Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

Data not display when klick swicth category

  Asked By: Arland    Date: Apr 03    Category: Asp.net    Views: 5547
  

i any problem in myscript, data not display when klick swicth kategori,
thereabouts where problem's my script
script :



<%@ Page Language="vb" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">

Sub Getkategori_Click(Sender As Object, E As EventArgs)

Dim DS As DataSet
Dim MyConnection As SqlConnection
Dim MyCommand As SqlDataAdapter


Dim SelectCommand As String = "select * from buku where kategori =
@kategori"

MyCommand = New SqlDataAdapter(SelectCommand, MyConnection)

MyCommand.SelectCommand.Parameters.Add(New SqlParameter("@kategori",
SqlDbType.NVarChar, 2))
MyCommand.SelectCommand.Parameters("@kategori").Value = Myselect.Value

DS = new DataSet()
MyCommand.Fill(DS, "buku")

MyDataGrid.DataSource=DS.Tables("buku").DefaultView
MyDataGrid.DataBind()
End Sub

</script>
<html>
<head>
</head>
<body style="FONT: 10pt verdana">
<form runat="server">
<h3><font face="Verdana">Buku Per Kategori</font>
</h3>
Select a Kategori:
<select id="MySelect" runat="server">
<option>Komik</option>
<option>Relaksasi</option>
<option>Sastra</option>
<option>Novel Lokal</option>
<option>Novel Import</option>
<option>Dunia Usaha</option>
<option>Kesehatan</option>
<option>Psikologi</option>
<option>Pendidikan</option>
</select>
<input type="submit" value="Kategori" runat="server"
onserverclick="getkategori_click" />
<p>
<ASP:DataGrid id="MyDataGrid" runat="server"
EnableViewkategori="false" HeaderStyle-BackColor="#6699ff" Font-Size="8pt"
Font-Name="Verdana" CellSpacing="0" CellPadding="3" ShowFooter="false"
BorderColor="black" BackColor="#ccccff" Width="700"></ASP:DataGrid>
</p>
</form>
</body>
</html>

Share: 

 

6 Answers Found

 
Answer #1    Answered By: Wilfred Young     Answered On: Apr 03

The DS object  is filled properly by Fill method ?

 
Answer #2    Answered By: William Bouchard     Answered On: Apr 03

Try:


<asp:DropDownList id="MySelect" runat="server" >
<asp:ListItem>Komik</asp:ListItem>
<asp:ListItem>Relaksasi</asp:ListItem>
<asp:ListItem>Sastra</asp:ListItem>
<asp:ListItem>Novel Lokal</asp:ListItem>
<asp:ListItem>Novel Import</asp:ListItem>
<asp:ListItem>Dunia Usaha</asp:ListItem>
<asp:ListItem>Kesehatan</asp:ListItem>
<asp:ListItem>Psikologi</asp:ListItem>
<asp:ListItem>Pendidikan</asp:ListItem>
</asp:DropDownList>
<asp:Button Text="Kategori" runat="server" onclick="getkategori_click"
/>

 
Answer #3    Answered By: Jean Bell     Answered On: Apr 03

The value of 2 of the parameter's width is correct ?
Try and put a breakpoint in script function and run in debug mode... to see
what's happening.
The IDE allows you to debug the scripts.

 
Answer #4    Answered By: Dominic Murphy     Answered On: Apr 03

I have a question How are you reading the value
of the selected ListItem? In your Getkategori_Click()
event handler you need to access the Request
object to get the value of the MySelect.SelectedItem.Text
or something similar to pass to @kategori and make your
query work.

 
Answer #5    Answered By: Jeffrey Washington     Answered On: Apr 03

if anybody knows answer for this question please send
it to quickly

1.How would you get ASP.NET running in Apache web
servers - why would you even do this?

2.what is meant by Line Item dimension?

 
Answer #6    Answered By: Landra Schmidt     Answered On: Apr 03

1. Yes you can
weblogs.asp.net/.../424852.aspx

2. www.dmreview.com/article_sub.cfm?articleId=7844

I see a lot of google in your future...

 
Didn't find what you were looking for? Find more on Data not display when klick swicth category Or get search suggestion and latest updates.




Tagged: