<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" Width="900px" ShowFooter="True" DataKeyNames="UQD_ID"> <Columns> <asp:BoundField HeaderText="Subject" DataField="UQD_Subject" /> <asp:BoundField HeaderText="Query" DataField="UQD_Description" /> <asp:BoundField HeaderText="Query Date" DataField="UQD_InsertDate" /> <asp:TemplateField HeaderText="Reply"> <ItemTemplate> <asp:TextBox ID="txtReply" runat="server"></asp:TextBox> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Is Reply"> <ItemTemplate> <asp:CheckBox ID="chk" runat="server" /> </ItemTemplate> <FooterTemplate> <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" /> </FooterTemplate> </asp:TemplateField> </Columns> <FooterStyle BackColor="White" ForeColor="#000066" /> <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" /> <RowStyle ForeColor="#000066" /> <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" /> <SortedAscendingCellStyle BackColor="#F1F1F1" /> <SortedAscendingHeaderStyle BackColor="#007DBB" /> <SortedDescendingCellStyle BackColor="#CAC9C9" /> <SortedDescendingHeaderStyle BackColor="#00547E" /> </asp:GridView>
public partial class AdminReply : System.Web.UI.Page { string con = ConfigurationManager.ConnectionStrings["conn"].ConnectionString; DataSet ds = new DataSet(); SqlParameter[] param; protected void Page_Load(object sender, EventArgs e) { if(!IsPostBack) { BindGrid(); } } private void BindGrid() { ds = SqlHelper.ExecuteDataset(con, CommandType.StoredProcedure, "UQAdminView"); GridView1.DataSource=ds; GridView1.DataBind(); } protected void btnSubmit_Click(object sender, EventArgs e) { int UQD_ID; foreach (GridViewRow Row in GridView1.Rows) { if (((CheckBox)Row.FindControl("chk")).Checked) { UQD_ID = Convert.ToInt32(GridView1.DataKeys[Row.RowIndex].Values); bool IsReply = ((CheckBox)Row.FindControl("chk")).Checked; string Reply = ((TextBox)Row.FindControl("txtReply")).Text; param = new SqlParameter[3]; param[0] = new SqlParameter("@UQD_ReplyDescription", Reply); param[1] = new SqlParameter("@UQD_IsReply", IsReply); param[2] = new SqlParameter("@UQD_ID", UQD_ID); SqlHelper.ExecuteNonQuery(con, CommandType.StoredProcedure, "UQAdminUpdateReply", param); } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)