前台
<EmptyDataTemplate> <table> <tr style="color: Black; background-color: SkyBlue; font-weight: bold;"> <th scope="col" style="width: 10px;"> </th> <th scope="col" style="width: 190px;"> 名称 </th> <th scope="col" style="width: 194px;"> 键值 </th> <th> </th> </tr> <tr> <td> </td> <td> <asp:TextBox ID="txtName" runat="server" MaxLength="100" CssClass="input_text"></asp:TextBox> </td> <td> <asp:TextBox ID="txtCode" runat="server" MaxLength="16" CssClass="input_text"></asp:TextBox> </td> <td> <asp:LinkButton ID="linkBtnInsert" runat="server" CommandName="Add">新增</asp:LinkButton> </td> </tr> </table> </EmptyDataTemplate>
后台
/// <summary> /// GridView事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvFieldValue_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("Add")) { GridViewRow row = (GridViewRow)((e.CommandSource as LinkButton).NamingContainer);//获取值 string txtName = (row.FindControl("txtName") as TextBox).Text; string txtCode = (row.FindControl("txtCode") as TextBox).Text;
}
}
|
请发表评论