评级控制不在asp.net2.0中使用 [英] Rating control not use in asp.net2.0

查看:75
本文介绍了评级控制不在asp.net2.0中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iam using Rating control in my asp.net(2.0) application but it is not executed one error has come but im not getting how will i solve that error here im paste my cs code 





cs



cs

protected void Page_Load(object sender, EventArgs e)
    {
       
        con = new SqlConnection("Data Source=ADMIN\\SQLEXPRESS;Initial Catalog=Example; Integrated Security=true");
        if (!IsPostBack)
        {
            rating();

        }

    }

    protected void RatingControlChanged(object sender, AjaxControlToolkit.RatingEventArgs e)
    {
        con.Open();
        cmd = new SqlCommand("insert into Rating_Details(Rate)values(@Rating)", con);
        cmd.Parameters.AddWithValue("@Rating", ratingControl.CurrentRating);
        cmd.ExecuteNonQuery();
        con.Close();
        rating();
        Response.Write("thank you for ur rating");
    }


    protected void rating()
    {

        int total = 0;

        DataTable dt = new DataTable();
        con.Open();
        SqlCommand cmd = new SqlCommand("Select Rate from Rating_Details", con);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        da.Fill(dt);
        if (dt.Rows.Count>0)//breakpoint not enter in if condition
        {
            for (int i = 0; i<dt.Rows.Count; i++)
            {
                total += Convert.ToInt32(dt.Rows[i][0].ToString());
            }
            int average = total / (dt.Rows.Count);
            ratingControl.CurrentRating = average;
            lbltxt.Text = dt.Rows.Count + "user(s) have rated this article";
        }

    }





im degab code但是在da.Fill(dt)之后;如果条件有任何解决方案,方法中的断点不进入



aspx代码





im degab code but after da.Fill(dt); breakpoint out in method it is not going in if condition any solution please

aspx code

<pre lang="xml"><body>
<form id="form1" runat="server">
<%--<ajax:ToolkitScriptManager ID="ScripManager1" runat="server"/>
--%><div>
 <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
<asp:UpdatePanel ID="pnlRating" runat="server">
<ContentTemplate>
<table width="35%">
<tr>
<td width="27%">
<b>Average Rating:</b>
</td>
<td>
<ajaxToolkit:Rating ID="ratingControl" CurrentRating="0" MaxRating="5" RatingAlign="Horizontal" AutoPostBack="true" OnChanged="RatingControlChanged" runat="server" StarCssClass="ratingStar" WaitingStarCssClass="ratingSaved" EmptyStarCssClass="ratingEmpty" FilledStarCssClass="ratingFilled" >
</ajaxToolkit:Rating>
<b> <asp:label ID="lbltxt" runat="server"/> </b>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>

</div>
</form>
</body>





css



css

<%@ Register
    Assembly="AjaxControlToolkit"
    Namespace="AjaxControlToolkit"
    TagPrefix="ajaxToolkit" %>
     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Ajax Rating Sample</title>
<style type="text/css">

.ratingStar
    {
        font-size: 0pt;
        width: 12px;
        height: 12px;
        cursor: pointer;
        background-repeat: no-repeat;
        display: block;
    }

.ratingEmpty
{
background-image: url(ratingStarEmpty.gif);
width:18px;
height:18px;
}
.ratingFilled
{
background-image: url(ratingStarFilled.gif);
width:18px;
height:18px;
}
.ratingSaved
{
 background-image: url(ratingStarSaved.gif);
width:18px;
height:18px;
}

</style>
</head>

推荐答案

Hello Atul Rokade,

如你提到的那样控制是不是如果条件那么你知道这是评级表中可用的数据
Hello Atul Rokade,
as you mentioned that control is not going to if condition so do you know that is data available in rating table


我无法理解你想做什么,所以请详细解释你的问题比我将试着帮助你
i could not understand that what you do you want so please explain in detail what is your issue than i will try to help out you


点击这些链接或者通过你的完整代码aspx和.cs



http://imar.spaanjaars.com/410/building-a-simple-rating-control- for-aspnet-20 [ ^ ]
follow these link or past your complete code aspx and .cs

http://imar.spaanjaars.com/410/building-a-simple-rating-control-for-aspnet-20[^]


这篇关于评级控制不在asp.net2.0中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆