in Education by
So the problem is i don't get get a value from textbox field on GridView RowUpdating event. Here is HTML ASP.net code: <%-- <asp:LinkButton ID="Button_delete" runat="server" CausesValidation="false" CommandName="delete" CssClass="btn btn-xs btn-danger" ToolTip="Izbriši"> --%> And here is code behind: protected void Grid_Reload(int i) { DB db = new DB(); if (i == 0 || i == 1) { SqlDataSource1.ConnectionString = db.GetConnString(); GridView1.DataBind(); } if (i == 0 || i == 2) { SqlDataSource2.ConnectionString = db.GetConnString(); GridView2.DataBind(); } if (i == 0 || i == 3) { SqlDataSource3.ConnectionString = db.GetConnString(); GridView3.DataSource = SqlDataSource3; GridView3.DataBind(); } } protected void GridView3_RowUpdating(object sender, GridViewUpdateEventArgs e) { String warning_msg = "", error_msg = "", info_msg = "", success_msg = ""; int i = 0; Commons cm = new Commons(); try { GridViewRow row = (GridViewRow)GridView3.Rows[e.RowIndex]; int periodid = Convert.ToInt32(GridView3.DataKeys[e.RowIndex].Values[0]); string workerid = GridView3.DataKeys[e.RowIndex].Values[1].ToString(); TextBox field1 = (TextBox)row.Cells[2].Controls[0]; String SQL = "update _utJN_EvidencaDCSum set acReason = '" + field1.Text + "' where anPeriodID = '" + periodid.ToString() + "' and acWorkerID = '" + workerid + "'"; DB db = new DB(); db.ExecSQL(SQL); GridView3.EditIndex = -1; Grid_Reload(3); } catch (Exception ex) { error_msg = ex.Message; } finally { i = cm.SetMessage(LabelError, error, error_msg, LabelWarning, warning, warning_msg, LabelInfo, info, info_msg, LabelSuccess, success, success_msg); } if (i == 1) { ClientScript.RegisterStartupScript(this.GetType(), "hash", "location.hash = '#msg';", true); } } protected void GridView3_RowEditing(object sender, GridViewEditEventArgs e) { GridView3.EditIndex = e.NewEditIndex; Grid_Reload(3); } protected void GridView3_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) { GridView1.EditIndex = -1; Grid_Reload(3); } The problem is I assume here: TextBox field1 = (TextBox)row.Cells[2].Controls[0]; But I cannot figure it out. I have almost identical example, but it's working perfectly. Other method (that one is working just fine): protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { String warning_msg = "", error_msg = "", info_msg = "", success_msg = ""; int i = 0; Commons cm = new Commons(); try { GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex]; int id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0]); TextBox field1 = (TextBox)row.Cells[1].Controls[0]; String SQL = "update _utJN_Holidays set acText = '" + field1.Text + "' where anID = '" + id.ToString()+ "'"; DB db = new DB(); db.ExecSQL(SQL); GridView1.EditIndex = -1; Grid_Reload(); } catch (Exception ex) { error_msg = ex.Message; } finally { i = cm.SetMessage(LabelError, error, error_msg, LabelWarning, warning, warning_msg, LabelInfo, info, info_msg, LabelSuccess, success, success_msg); } if (i == 1) { ClientScript.RegisterStartupScript(this.GetType(), "hash", "location.hash = '#msg';", true); } } I tried also this: //Loop through all Cells in the Row. int index = 0; foreach (TableCell cell in row.Cells) { if (cell.Controls.Count > 0) { //Check whether Cell has TextBox. if (cell.Controls[0] is TextBox) { //Reference the TextBox. TextBox textBox = cell.Controls[0] as TextBox; textBox.ID = "txtReason"; //warning_msg += "xx" + GridView3.HeaderRow.Cells[index].Text + "xx" + index.ToString(); } } index++; } //TextBox field1 = (TextBox)row.Cells[2].Controls[0]; TextBox field1 = (TextBox)row.FindControl("txtReason"); String SQL = "update _utJN_EvidencaDCSum set acReason = '" + field1.Text + "' where anPeriodID = '" + periodid.ToString() + "' and acWorkerID = '" + workerid + "'"; and its still empty.. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
you could do it another way as put TextBox textname = (TextBox)row.FindControl("your textbox id"); and then use its value where you want code behind

Related questions

0 votes
    I have been developing a webpage which uses n number of dropdownlists which are binding dynamically inside a ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 18, 2022 in Education by JackTerrance
0 votes
    For example, I have an ASP.NET form that is called by another aspx: string url = "http:// ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    I'm working on a DNN skin using Christoc's DNN templates and when I create a normal ASP.NET ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 26, 2022 in Education by JackTerrance
0 votes
    I have a Login control placed inside LoginView control contained within a PANEL. I want to set login button ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 8, 2022 in Education by JackTerrance
0 votes
    I have a database (SQL Server) with clients and a MVC plataform, and i want a row to be "hidden ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I have a database (SQL Server) with clients and a MVC plataform, and i want a row to be "hidden ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    i create this class and it have this constructor : public class ReturnResult : ImplicitReturnResult { public bool ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    I have tried many solution online but I am unable to fix. First off all i check in bin and it ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I am using a user control and I need to call a popup, which asks a question, and I need to send ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I've got a Sharepoint WebPart which loads a custom User Control. The user control contains a Repeater which ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 22, 2022 in Education by JackTerrance
0 votes
    I've got a Sharepoint WebPart which loads a custom User Control. The user control contains a Repeater which ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    I've got a Sharepoint WebPart which loads a custom User Control. The user control contains a Repeater which ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    I've got a Sharepoint WebPart which loads a custom User Control. The user control contains a Repeater which ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    Need to read my SMTP email settings defined under system.net section in my web.config file. Below is one example of SMTP email setting defined in web.config file: (Under Section)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    How to get the container TreeView of a TreeNode ?? Thank you all. JavaScript questions and answers, ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
...