我有一个gridview,我正在尝试选择行ID(UrunId)。这是我的aspx:
<asp:GridView ID="GridViewHdcvi" runat="server" DataSourceID="EntityDataSourceHdcvi" AutoGenerateColumns="False" DataKeyNames="UrunId">
<Columns>
<asp:TemplateField HeaderText="Sil">
<ItemTemplate>
<asp:LinkButton ID="deleteProduct" runat="server" Text="Satırı Sil" CommandName="deleteProduct">
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Sil" Visible="false">
<ItemTemplate>
<%#Eval("UrunId") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ÜRÜN VE DETAYLARI">
<ItemStyle Width="400px" />
<ItemTemplate>
<div style="color: red" class="text-center"><%#Eval("UrunAdi") %></div>
<%#Eval("UrunDetay") %>
</ItemTemplate>
</asp:TemplateField>
<asp:ImageField HeaderText="ÜRÜN GÖRSELİ" DataImageUrlField="UrunResim"></asp:ImageField>
<asp:TemplateField HeaderText="BİRİM FİYAT">
<ItemTemplate>
<%#Eval("UrunFiyati") %>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ADET">
<ItemTemplate>
<asp:TextBox ID="txtAdet" runat="server" Width="40px"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
正如您所看到的,我不希望用户看到我的&#34; UrunId&#34;列,但当用户点击&#34; deleteProduct&#34;时,我需要在代码隐藏中获取该行的UrunId。谢谢你的时间。
答案 0 :(得分:0)
.ASPX标记
pm<-proc.time()
vys<-((x1==37) | (x2==37) | (x3==37) | (x4==37) | (x5==37) | (x6==37) | (x7==37) | (x8==37) | (x9==37) | (x10==37))
proc.time() - pm
# user system elapsed
# 0.05 0.13 0.93
pm<-proc.time()
vys1 <- dt[, Reduce('|', lapply(.SD, '==', 37)), .SDcols= x1:x10]
proc.time() - pm
# user system elapsed
# 0.05 0.03 0.08
背后的代码
<asp:TemplateField HeaderText="Sil">
<ItemTemplate>
<asp:LinkButton ID="deleteProduct" runat="server" Text="Satırı Sil" CommandArgument='<%#Eval("UrunId")%>' CommandName="deleteProduct" OnClick="LinkButton_Click">
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
OR
protected void LinkButton_Click(Object sender, EventArgs e)
{
LinkButton btn=(LinkButton)sender;
int Id= Convert.toInt32(btn.CommandArgument);
//Your delete code here
}