Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 如何从gridview检索选中行的主键_Asp.net_Oracle10g - Fatal编程技术网

Asp.net 如何从gridview检索选中行的主键

Asp.net 如何从gridview检索选中行的主键,asp.net,oracle10g,Asp.net,Oracle10g,您能告诉我如何在网格视图中检索选中行的主键吗?我不想显示该值或其他内容,只需使用它修改特定行(删除、更改列值等) 我在后端使用Oracle 10g。 谢谢。使用gridview的数据键 详情:- 在Aspx.Page中 <asp:GridView ID="gv" runat="server" AutoGenerateColumns="False" DataKeyNames="emp_id"> 在Cs.Page中, 在点击事件中 for(int i=0;i<gv

您能告诉我如何在网格视图中检索选中行的主键吗?我不想显示该值或其他内容,只需使用它修改特定行(删除、更改列值等) 我在后端使用Oracle 10g。
谢谢。

使用gridview的数据键

详情:-

在Aspx.Page中

<asp:GridView ID="gv" runat="server" AutoGenerateColumns="False"  
    DataKeyNames="emp_id">

在Cs.Page中, 在点击事件中

for(int i=0;i<gv.rows.count;i++)
{
    GridviewRow row=gv.rows[i];
    cheakbox c1=(Cheakbox)row.FindControl("chkId");
    if(c1.cheaked)
    {
         int id=Convert.toInt32(gv.Datakeys[i]);
    }
}
for(inti=0;i试试这个

 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="ProductId" AllowPaging="True" 
        BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" 
        CellPadding="2" ForeColor="Black" GridLines="None" 
        onpageindexchanging="GridView1_PageIndexChanging" 
        onrowediting="GridView1_RowEditing" onrowupdating="GridView1_RowUpdating" 
        onrowcancelingedit="GridView1_RowCancelingEdit" 
        onrowdeleting="GridView1_RowDeleting" Width="603px">
  </asp:GridView>

你需要写代码来实现你想要的…我建议你先写一些代码…然后再问问题。嘿,这很有帮助..谢谢你:)如果我的答案对你有帮助,请记下我的答案。点击我答案左侧的勾号。
 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="ProductId" AllowPaging="True" 
        BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" 
        CellPadding="2" ForeColor="Black" GridLines="None" 
        onpageindexchanging="GridView1_PageIndexChanging" 
        onrowediting="GridView1_RowEditing" onrowupdating="GridView1_RowUpdating" 
        onrowcancelingedit="GridView1_RowCancelingEdit" 
        onrowdeleting="GridView1_RowDeleting" Width="603px">
  </asp:GridView>
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
    int productid=int.Parse(GridView1.DataKeys[e.RowIndex].Values[0].ToString());
}