Click here to Skip to main content
16,017,151 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello....
How to pass two datakey values through querystring in gridviewediting command..
Posted

Just pass complete item.You can get valueof each column from Dataitem.
Each row can have only one dataKey Value Not more then that
 
Share this answer
 
String 1stquerystring=gridview.DataKeys[e.NewEditIndex].Values["Datakey1"].ToString();

String 2ndquerystring=gridview.DataKeys[e.NewEditIndex].Values["Datakey2"].ToString();
 
Share this answer
 
C#
<asp:gridview id="GridView1" runat="server" autogeneratecolumns="false" datakeynames="tprice,tquantity" onselectedindexchanged="GridView1_SelectedIndexChanged" xmlns:asp="#unknown">
        <columns>
 <asp:commandfield showselectbutton="true" />
        </columns>
        </asp:gridview>


C#
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
  {
      string tprice2 = Server.HtmlDecode(GridView1.SelectedDataKey["tprice"].ToString());
      string tquantity1 = Server.HtmlDecode(GridView1.SelectedDataKey["tquantity"].ToString());
  }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900