????????GridView??????????????????????????е?????????????????????????????磬???????????????????????????????????????????????????????GridView?????????????????
?????????
?????? ???????GridView??RowCommand?????????С?
?????? ????棺??GridView??????????У???????????LinkButton?????
????????
????<asp:TemplateField HeaderText="????">
????<ItemTemplate>
????<asp:LinkButton ID="lbtnQianRu" runat="server" CommandName="QianRu"
????CommandArgument='<%# Eval("Id") %>'>???</asp:LinkButton>
????<asp:LinkButton ID="lbtnQianChu " runat="server" CommandName="QianChu">??? </asp:LinkButton>
????</ItemTemplate>
????</asp:TemplateField>
????С????????????????????e.CommandArgument??????????????????????????CommandArgument??????????????????Ρ??磺
????//????????????????LinkButton??CommandArgument??????Id?????????????????????e.CommandArgument?ó?????ID???
????int id = Convert.ToInt32(e.CommandArgument.ToString());
?????? ??GridView???????????LinkButton????????????????????·????????????
????protected void gv_Company_RowCommand(object sender?? GridViewCommandEventArgs e){
????if (e.CommandName == "QianRu")
????{
?????????????
????GridViewRow drv = ((GridViewRow)(((LinkButton)(e.CommandSource)).Parent.Parent)); //??ó???????????б???е??????
????inf id=Convert.ToInt32(GridView1.DataKeys[drv.RowIndex].Value); //????????GridView?а???????е??????
??????????????????????GridView??DataKeyNames?????????????????????????????Ρ?
??????????????
????GridViewRow drv = (GridViewRow)((LinkButton)e.CommandSource).NamingContainer;//??ó???????????б???е??????
????int id = Convert.ToInt32(GridView1.Rows[drv.RowIndex].Cells[0].Text); //????????GridView?а???????е??????????????????е????е????е????drv.RowIndex?????????е?????
????}
????}
?????????????Щ????????????????????????
??????????????
??????linkbutton?????Command?????????sender??Parent???GridView?е????С?
????protected void lbtnQianChu_Command(object sender?? CommandEventArgs e)
????{
????LinkButton lb = (LinkButton)sender;
????DataControlFieldCell dcf = (DataControlFieldCell)lb.Parent;
????GridViewRow gvr = (GridViewRow)dcf.Parent; //??ó???????????б???е??????
????lbtnQianChu.SelectedIndex = gvr.RowIndex;
????}
?????????????
??????linkbutton?????Click????????GridView?е????С?
????protected void LinkButton1_Click(object sender?? EventArgs e)
????{
????//?к?
????int row = ((GridViewRow)((LinkButton)sender).NamingContainer).RowIndex;
????}