hello all,
i want do the edit the textbox in gridview but edited textbox value doesnt get and effect....please see the below code
<td><cc:GridViewEx ID="gvCheckboxes" runat="server" AutoGenerateColumns="False" DataKeyNames="question_id" OnRowDataBound="gvCheckboxes_RowDataBound" OnDataSourceRequested="gvCheckboxes_DataSourceRequested" EmptyDataText="No Record Found" Width="100%" AutoGenerateEditButton="True" OnRowCancelingEdit="gvCheckboxes_RowCancelingEdit" OnRowEditing="gvCheckboxes_RowEditing" OnRowUpdating="gvCheckboxes_RowUpdating"><Columns><asp:TemplateField ItemStyle-Width="5%"><HeaderTemplate><asp:CheckBox ID="ChkAll" runat="server" OnClick="javascript:SelectheaderCheckboxes(this)" /></HeaderTemplate><ItemTemplate><asp:CheckBox ID="chkQuestion" runat="server" Checked='<%#Eval("flg_checked")%>' OnClick="javascript:SelectheaderCheckboxes(this)" /></ItemTemplate></asp:TemplateField><asp:TemplateField Visible="false"><HeaderTemplate><asp:Label ID="lblQuestionId" runat="server" Text="Question_Id"></asp:Label></HeaderTemplate><ItemTemplate><asp:Label ID="lblQuestionIdText" runat="server" Text='<%#Eval("question_id")%>'></asp:Label></ItemTemplate></asp:TemplateField><asp:BoundField HeaderText="Question Text" DataField="question_text"><HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="50px" /><ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="50px" /></asp:BoundField><asp:TemplateField HeaderText="Suggestion"><ItemTemplate><%#Eval("Suggestion")%></ItemTemplate><EditItemTemplate><asp:TextBox ID="txtSuggestion" runat="server" Text='<%#Bind("Suggestion") %>'></asp:TextBox></EditItemTemplate></asp:TemplateField><%-- <asp:TemplateField HeaderText="Edit" ItemStyle-Width="5%"><ItemTemplate><asp:ImageButton ID="imgbtn" ImageUrl="~/images/icon-pencil.gif" runat="server" Width="25" Height="25" OnClick="imgbtn_Click" OnClientClick="ClearTxt();return true;" /></ItemTemplate></asp:TemplateField>--%></Columns></cc:GridViewEx></td>
protected void gvCheckboxes_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) { gvCheckboxes.EditIndex = -1; gvCheckboxes.BindDataSource(); } protected void gvCheckboxes_RowEditing(object sender, GridViewEditEventArgs e) { gvCheckboxes.EditIndex = e.NewEditIndex; gvCheckboxes.BindDataSource(); } protected void gvCheckboxes_RowUpdating(object sender, GridViewUpdateEventArgs e) { DataTable dtQuestion = new DataTable(); if (ViewState["Question"] != null) { dtQuestion = (DataTable)ViewState["Question"]; } // TextBox txtSuggestion= ((TextBox)(gvCheckboxes.Rows[e.RowIndex].Cells[3].FindControl("txtSuggestion"))); GridViewRow row = gvCheckboxes.Rows[e.RowIndex];
i havent get it updated value of textbox....why this is happened i dont know
TextBox txtSuggestion = (TextBox)row.FindControl("txtSuggestion"); dtQuestion.Rows[row.DataItemIndex]["Suggestion"] = txtSuggestion.Text;
gvCheckboxes.EditIndex = -1;
gvCheckboxes.BindDataSource();
}
in above code i have edit suggestion text and entered new value but i doesnt get it updated value...if any one have any idea about this then please let me know as earlier as possible.
Any help will be appriciated.
Thanks in advance.
Khushboo nayak