如何在gridview中显示ajax评级 [英] How to display ajax rating in gridview

查看:88
本文介绍了如何在gridview中显示ajax评级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在DataGrid中显示Ajax等级。错误是

i am trying to display Ajax Rating in the DataGrid..error is "

Specified cast is not valid."

。什么是使用Ajax等级的最佳方法Gridview?



我的尝试:



.What is the best way to use Ajax Rating in the Gridview?

What I have tried:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:iuploadConnectionString %>" 
        SelectCommand="SELECT * FROM [tb_Gallery]"></asp:SqlDataSource>
    
    <br />
    <cc1:ToolkitScriptManager ID="ToolkitScriptManager2" runat="server">
    </cc1:ToolkitScriptManager>

                <asp:GridView ID="GridView2" runat="server"
                 
                    BackColor="White" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" 
                    CellPadding="4"  
                    Width="69px"  
        
                   >
       
          
        
                    <Columns>
                    <%--here i am using templatefields to for binding the gridview--%>
                        <asp:TemplateField HeaderText="Album_name">
                            <EditItemTemplate>
                           
                     <%--here i am using the textbox in the edititmtemplatefield to upadate the data--%>
                                <asp:TextBox ID="txt_album_name" runat="server"
                                    Text='<%# Eval("album_name") %>'></asp:TextBox>
                                <asp:Label ID="Label4" runat="server" Text='<%# Eval("id") %>' Visible="False"></asp:Label>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Eval("album_name") %>'></asp:Label>
                                <asp:Label ID="Label2" runat="server" Text='<%# Eval("id") %>' Visible="False"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Caption">
                            <EditItemTemplate>
                                <asp:TextBox ID="txt_caption" runat="server" Text='<%# Eval("caption") %>'></asp:TextBox>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label3" runat="server" Text='<%# Eval("caption") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Image">
                        <ItemTemplate>
                        <%--for displaying the image inside the gidview here i'm using the <img>tag
                        and specify the path of the folder where image is stored--%>
                        <img alt ="" src ='images/<%#Eval("image") %>' height="200px" width="200px"/>
                        </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Delete">
                        <%--here i am using the linkbutton to delete the record and specify the command name
                        of this linkbutton is delete--%>
                            <ItemTemplate>
                                <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False"
                                    CommandName="Delete"
                                    onclientclick="return confirm('are you sure you want to delet this column')">Delete</asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Update">
                            <EditItemTemplate>
                           <%-- here i am using the s linkbuttons to update the record and a  cancel button
                           and set the commandname of update button is update and the cancel button is cancel --%>
                                <asp:LinkButton ID="LinkButton3" runat="server" CausesValidation="False"
                                    CommandName="Update">Update</asp:LinkButton>
                                <asp:LinkButton ID="LinkButton4" runat="server" CausesValidation="False"
                                    CommandName="Cancel">Cancel</asp:LinkButton>
                            </EditItemTemplate>
                            <ItemTemplate>
                                
                               <%--here i am using the linkbutton for edit and specify the command name
                        of this linkbutton is Edit--%>
                                <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False"
                                    CommandName="Edit">Edit</asp:LinkButton>
                            </ItemTemplate>
                        
                        </asp:TemplateField>
        <asp:TemplateField HeaderText="Rating">
            <ItemTemplate>
                <cc1:Rating ID="Rating1" AutoPostBack="true"  runat="server"
                    StarCssClass="Star" WaitingStarCssClass="WaitingStar" EmptyStarCssClass="Star"
                    FilledStarCssClass="FilledStar" CurrentRating='<%# Eval("Rating") %>'>
                </cc1:Rating>
            </ItemTemplate>
        </asp:TemplateField>
                       
                    </Columns>
                    <EditRowStyle BorderWidth="60px" Width="60px" />
                    <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
                    <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
                    <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
                    <RowStyle BackColor="#999999" ForeColor="#003399" Width="70px" />
                    <SelectedRowStyle BackColor="Blue" Font-Bold="True" ForeColor="#CCFF99" 
                        BorderColor="#0066CC" />
                    <SortedAscendingCellStyle BackColor="#EDF6F6" />
                    <SortedAscendingHeaderStyle BackColor="#0D4AC4" />
                    <SortedDescendingCellStyle BackColor="#D6DFDF" />
                    <SortedDescendingHeaderStyle BackColor="#002876" />
                </asp:GridView>
   
    <cc1:Rating ID="Rating2" runat="server">
    </cc1:Rating>
    <cc1:Rating ID="Rating1" runat="server">
    </cc1:Rating>
  
   
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
        ConnectionString="<%$ ConnectionStrings:iuploadConnectionString %>" 
        SelectCommand="SELECT * FROM [Ratings]"></asp:SqlDataSource>

推荐答案

ConnectionStrings:iuploadConnectionString %>
SelectCommand =SELECT * FROM [tb_Gallery]>< / asp:SqlDataSource>

< br />
< cc1:ToolkitScriptManager ID =ToolkitScriptManager2runat =server>
< / cc1:ToolkitScriptManager>

< asp:GridView ID =GridView2runat =server

BackColor =WhiteBorderColor =#3366CCBorderStyle =NoneBorderWidth =1px
CellPadding =4
Width =69px

>



< Columns>
<% - 这里我使用templatefields来绑定gridview - %>
< asp:TemplateField Heade rText = ALBUM_NAME >
< EditItemTemplate>

<% - 这里我使用edititmtemplatefield中的文本框来更新数据 - %>
< asp:TextBox ID =txt_album_namerunat =server
Text ='<%#Eval(album_name)%>'>< / asp:TextBox>
< asp:Label ID =Label4runat =serverText ='<%#Eval(id)%>'Visible =False>< / asp:Label>
< / EditItemTemplate>
< ItemTemplate>
< asp:Label ID =Label1runat =serverText ='<%#Eval(album_name)%>'>< / asp:Label>
< asp:Label ID =Label2runat =serverText ='<%#Eval(id)%>'Visible =False>< / asp:Label>
< / ItemTemplate>
< / asp:TemplateField>
< asp:TemplateField HeaderText =Caption>
< EditItemTemplate>
< asp:TextBox ID =txt_captionrunat =serverText ='<%#Eval(caption)%>'>< / asp:TextBox>
< / EditItemTemplate>
< ItemTemplate>
< asp:Label ID =Label3runat =serverText ='<%#Eval(caption)%>'>< / asp:Label>
< / ItemTemplate>
< / asp:TemplateField>
< asp:TemplateField HeaderText =Image>
< ItemTemplate>
<% - 用于在gidview中显示图像我在这里使用< img>标记
并指定存储图像的文件夹的路径 - %>
< img alt =src ='images /<%#Eval(image)%>'height =200pxwidth =200px/>
< / ItemTemplate>
< / asp:TemplateField>
< asp:TemplateField HeaderText =删除>
<% - 这里我使用linkbutton删除记录并指定命令名称
此链接按钮是删除 - %>
< ItemTemplate>
< asp:LinkBut​​ton ID =LinkBut​​ton1runat =serverCausesValidation =False
CommandName =Delete
onclientclick =return confirm('你确定要吗? delet this column')>删除< / asp:LinkBut​​ton>
< / ItemTemplate>
< / asp:TemplateField>
< asp:TemplateField HeaderText =Update>
< EditItemTemplate>
<% - 这里我使用s链接按钮来更新记录和取消按钮
并设置更新按钮的命令名是更新,取消按钮是取消 - %>
< asp:LinkBut​​ton ID =LinkBut​​ton3runat =serverCausesValidation =False
CommandName =Update> Update< / asp:LinkBut​​ton>
< asp:LinkBut​​ton ID =LinkBut​​ton4runat =serverCausesValidation =False
CommandName =Cancel>取消< / asp:LinkBut​​ton>
< / EditItemTemplate>
< ItemTemplate>

<% - 这里我使用linkbutton进行编辑,并指定命令名称
此链接按钮是编辑 - %>
< asp:LinkBut​​ton ID =LinkBut​​ton2runat =serverCausesValidation =False
CommandName =Edit> Edit< / asp:LinkBut​​ton>
< / ItemTemplate>

< / asp:TemplateField>
< asp:TemplateField HeaderText =Rating>
< ItemTemplate>
< cc1:评级ID =Rating1AutoPostBack =truerunat =server
StarCssClass =StarWaitingStarCssClass =WaitingStarEmptyStarCssClass =Star
FilledStarCssClass = FilledStarCurrentRating ='<%#Eval(Rating)%>'>
< / cc1:评分>
< / ItemTemplate>
< / asp:TemplateField>

< / Columns>
< EditRowStyle BorderWidth =60pxWidth =60px/>
< FooterStyle BackColor =#99CCCCForeColor =#003399/>
< HeaderStyle BackColor =#003399Font-Bold =TrueForeColor =#CCCCFF/>
< PagerStyle BackColor =#99CCCCForeColor =#003399Horizo​​ntalAlign =Left/>
< RowStyle BackColor =#999999ForeColor =#003399Width =70px/>
< SelectedRowStyle BackColor =BlueFont-Bold =TrueForeColor =#CCFF99
BorderColor =#0066CC/>
< SortedAscendingCellStyle BackColor =#EDF6F6/>
< SortedAscendingHeaderStyle BackColor =#0D4AC4/>
< SortedDescendingCellStyle BackColor =#D6DFDF/>
< SortedDescendingHeaderStyle BackColor =#002876/>
< / asp:GridView>

< cc1:评级ID =Rating2runat =server>
< / cc1:评分>
< cc1:评级ID =Rating1runat =server>
< / cc1:评分>


< asp:SqlDataSource ID =SqlDataSource3runat =server
ConnectionString =<%
ConnectionStrings:iuploadConnectionString %>" SelectCommand="SELECT * FROM [tb_Gallery]"></asp:SqlDataSource> <br /> <cc1:ToolkitScriptManager ID="ToolkitScriptManager2" runat="server"> </cc1:ToolkitScriptManager> <asp:GridView ID="GridView2" runat="server" BackColor="White" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" CellPadding="4" Width="69px" > <Columns> <%--here i am using templatefields to for binding the gridview--%> <asp:TemplateField HeaderText="Album_name"> <EditItemTemplate> <%--here i am using the textbox in the edititmtemplatefield to upadate the data--%> <asp:TextBox ID="txt_album_name" runat="server" Text='<%# Eval("album_name") %>'></asp:TextBox> <asp:Label ID="Label4" runat="server" Text='<%# Eval("id") %>' Visible="False"></asp:Label> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Eval("album_name") %>'></asp:Label> <asp:Label ID="Label2" runat="server" Text='<%# Eval("id") %>' Visible="False"></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Caption"> <EditItemTemplate> <asp:TextBox ID="txt_caption" runat="server" Text='<%# Eval("caption") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label3" runat="server" Text='<%# Eval("caption") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Image"> <ItemTemplate> <%--for displaying the image inside the gidview here i'm using the <img>tag and specify the path of the folder where image is stored--%> <img alt ="" src ='images/<%#Eval("image") %>' height="200px" width="200px"/> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Delete"> <%--here i am using the linkbutton to delete the record and specify the command name of this linkbutton is delete--%> <ItemTemplate> <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Delete" onclientclick="return confirm('are you sure you want to delet this column')">Delete</asp:LinkButton> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Update"> <EditItemTemplate> <%-- here i am using the s linkbuttons to update the record and a cancel button and set the commandname of update button is update and the cancel button is cancel --%> <asp:LinkButton ID="LinkButton3" runat="server" CausesValidation="False" CommandName="Update">Update</asp:LinkButton> <asp:LinkButton ID="LinkButton4" runat="server" CausesValidation="False" CommandName="Cancel">Cancel</asp:LinkButton> </EditItemTemplate> <ItemTemplate> <%--here i am using the linkbutton for edit and specify the command name of this linkbutton is Edit--%> <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Edit">Edit</asp:LinkButton> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Rating"> <ItemTemplate> <cc1:Rating ID="Rating1" AutoPostBack="true" runat="server" StarCssClass="Star" WaitingStarCssClass="WaitingStar" EmptyStarCssClass="Star" FilledStarCssClass="FilledStar" CurrentRating='<%# Eval("Rating") %>'> </cc1:Rating> </ItemTemplate> </asp:TemplateField> </Columns> <EditRowStyle BorderWidth="60px" Width="60px" /> <FooterStyle BackColor="#99CCCC" ForeColor="#003399" /> <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" /> <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" /> <RowStyle BackColor="#999999" ForeColor="#003399" Width="70px" /> <SelectedRowStyle BackColor="Blue" Font-Bold="True" ForeColor="#CCFF99" BorderColor="#0066CC" /> <SortedAscendingCellStyle BackColor="#EDF6F6" /> <SortedAscendingHeaderStyle BackColor="#0D4AC4" /> <SortedDescendingCellStyle BackColor="#D6DFDF" /> <SortedDescendingHeaderStyle BackColor="#002876" /> </asp:GridView> <cc1:Rating ID="Rating2" runat="server"> </cc1:Rating> <cc1:Rating ID="Rating1" runat="server"> </cc1:Rating> <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%


ConnectionStrings: iuploadConnectionString%>
SelectCommand =SELECT * FROM [Ratings]>< / asp:SqlDataSource>
ConnectionStrings:iuploadConnectionString %>" SelectCommand="SELECT * FROM [Ratings]"></asp:SqlDataSource>


这篇关于如何在gridview中显示ajax评级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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