我有一个问题,我想在下拉列表中的值被提取后,插入到数据库中我希望它隐藏下拉列表并只显示用户评分的产品等级,如下两个图片:
这是第一张显示用户需要如何将等级插入产品数据库的图片:
之后的结果应该如下:
对产品进行评分的用户现在应该看不到下拉列表。我尝试使用 RowDataBound 事件和以下代码:
if (e.Row.RowType == DataControlRowType.DataRow)
{
hsp_Narudzbe_Detalji_Result k = (hsp_Narudzbe_Detalji_Result)e.Row.DataItem;
if (k.Ocjena!=null)
{
e.Row.Cells[4].Text = k.ocjena;
}
}
但它不起作用,它只显示一次等级,当我按下产品分级按钮时,下拉列表又回来了......:/
有人可以帮我解决这个问题吗?
编辑(页面的aspx代码):
<asp:GridView ID="gridDetaljiNarudzbe" AutoGenerateColumns="false" AllowPaging="true" PageSize="10" runat="server" OnRowCommand="gridDetaljiNarudzbe_RowCommand" OnPageIndexChanging="gridDetaljiNarudzbe_PageIndexChanging" OnRowDataBound="gridDetaljiNarudzbe_RowDataBound">
<Columns>
<asp:BoundField DataField="Naziv" HeaderText="Naziv" />
<asp:BoundField DataField="Sifra" HeaderText="Šifra" />
<asp:BoundField DataField="Cijena" HeaderText="Cijena" />
<asp:BoundField DataField="Kolicina" HeaderText="Količina" />
<asp:TemplateField HeaderText="Ocjena">
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="btnOcijeni" title="Ocijeni proizvod" CommandName="OcijeniCommand" CommandArgument='<%#Eval("ProizvodID") + ";" +((GridViewRow) Container).RowIndex%>' runat="server"><img src="../images/ocijeni.png" /></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
成绩是这样加载的:
if (e.Row.RowType == DataControlRowType.DataRow)
{
DropDownList drop = e.Row.FindControl("DropDownList1") as DropDownList;
drop.Items.Add(new ListItem(""));
drop.Items.Add(new ListItem("1"));
drop.Items.Add(new ListItem("2"));
drop.Items.Add(new ListItem("3"));
drop.Items.Add(new ListItem("4"));
drop.Items.Add(new ListItem("5"));
}