Click here to Skip to main content
15,891,597 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<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>



C#
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);


            }
        }
    }
}
Posted
Comments
Prasad_Kulkarni 21-Dec-12 1:24am    
What is the prob man?
manpreetpawar 21-Dec-12 1:31am    
It Give poblem When i submit more than 1 entry ,it give error Out of range index
manpreetpawar 21-Dec-12 1:32am    
this code give error

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Prasad_Kulkarni 21-Dec-12 1:32am    
Have you tried debugging the code?
[no name] 21-Dec-12 1:25am    
elaborate your problem...

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