我想从每个记录的网格视图中获取我当前的老鼠并将其保存在我的数据库中。但我不能像网格视图中的其他控件一样调用它。如何在网格视图中保存每一行的费率?这是我在数据库表中的记录 ID:
int idx = Convert.ToInt32(e.CommandArgument);
idx = idx - (GridView2.PageSize * GridView2.PageIndex);
int ID = (int)GridView2.DataKeys[idx].Value;
我每一行都需要这个:
int rating = rating2.CurrentRating;
用于gridview的HTML代码:
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"
DataKeyNames="ID" DataSourceID="SqlDataSource1" Font-Names="Tahoma"
Font-Size="9pt" style="margin-left: 0px" Width="799px" GridLines="None">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<div style="width: 950px">
<table align="center" style="width: 100%;">
<tr>
<td align="center" colspan="3">
<div class="box1">
<div class="box-t">
<div class="b-l">
</div>
<div class="b-bg" dir="rtl">
<asp:Label ID="Label6" runat="server" Font-Names="Tahoma"
Text='<%# Eval("Title") %>'></asp:Label>
</div>
<div class="b-r">
</div>
</div>
<div class="box-bg">
<div class="content">
<table style="width: 100%; height: 8px;">
<tr>
<td align="right">
<div style="padding: 15px">
<asp:Label ID="Label10" runat="server" Font-Names="Tahoma" ForeColor="Black"
Text='<%# Eval("Body") %>'></asp:Label>
</div>
<br />
</td>
</tr>
<tr>
<td align="right">
<br />
<asp:Rating ID="Rating2" runat="server" CurrentRating="1" MaxRating="6" StarCssClass="ratingStar"
WaitingStarCssClass="savedRatingStar" FilledStarCssClass="filledRatingStar" EmptyStarCssClass="emptyRatingStar" style="float: right;" />
</td>
</tr>
<tr>
<td align="right">
<asp:Button ID="btnSubmit" runat="server"
CommandArgument="<%# Container.DataItemIndex %>" Font-Names="Tahoma"
Font-Size="9pt" oncommand="SubmitRating" Text="به این مطلب امتیاز دهید" />
</td>
</tr>
</table>
</div>
</div>
<div class="box-b">
<asp:Label ID="Label8" runat="server" Font-Italic="False" Font-Names="Homa"
Text=" تاریخ بارگذاری :"></asp:Label>
<asp:Label ID="Label11" runat="server" Font-Names="Homa"
Text='<%# JulianToPersianDate((DateTime)Eval("Date")) %>'></asp:Label>
</div>
</div>
</td>
</tr>
<tr>
<td align="center">
</td>
<td align="center">
</td>
<td align="center">
</td>
</tr>
</table>
</div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
任何身体都可以帮助我吗?