| | |
Textbox disappers due to post back and showed Error:Object reference not set to an in
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Apr 2007
Posts: 15
Reputation:
Solved Threads: 0
Textbox disappers due to post back and showed Error:Object reference not set to an in
0
#1 Jun 9th, 2009
I have a Gridview having 3 columns in which i took checkbox,label and label as item templates for columns select,code,name respectively.
ecode column is not editable.Button edit and update are present outside of gridview.
i can edit multiple rows like this...
when i select checkbox in 1st row of gridview then in ename column of that row i added textbox by this code
//here i set breakpoint and wanted to retrieve txteditEname but error comes...
then thinking that there is no such textbox when i press Update button as autopost back then
i saved the txteditEname 's value in Viewstate but when i retrieved viewstate it showed me the textbox's value before page is posted back.
But the current txteditEname's value is different which i want to update.Please tell me how to get curret txteditEname's value.
But before that i wonder if this textbox is not available then i'll surely get null value.
ecode column is not editable.Button edit and update are present outside of gridview.
i can edit multiple rows like this...
when i select checkbox in 1st row of gridview then in ename column of that row i added textbox by this code
ASP.NET Syntax (Toggle Plain Text)
protected void btnEdit_Click(object sender, EventArgs e) { for (int i = 0; i < GridView1.Rows.Count; i++) { txteditEname = new TextBox(); CheckBox chkDelete = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("chkSelect"); Label lblEname = (Label)GridView1.Rows[i].Cells[0].FindControl("lblEname"); if (chkDelete.Checked) { GridView1.Rows[i].Cells[2].Controls.Add(txteditEname); txteditEname.Text = lblEname.Text; lblEname.Visible = false; } } } protected void btnUpdate_Click(object sender, EventArgs e) { ArrayList al = new ArrayList(); for (int i = 0; i < GridView1.Rows.Count; i++) { CheckBox chkDelete = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("chkSelect"); txteditEname = (TextBox)GridView1.Rows[i].Cells[2].FindControl("txteditEname"); string str=txteditEname.Text;//error
//here i set breakpoint and wanted to retrieve txteditEname but error comes...
then thinking that there is no such textbox when i press Update button as autopost back then
i saved the txteditEname 's value in Viewstate but when i retrieved viewstate it showed me the textbox's value before page is posted back.
But the current txteditEname's value is different which i want to update.Please tell me how to get curret txteditEname's value.
But before that i wonder if this textbox is not available then i'll surely get null value.
Last edited by peter_budo; Jun 9th, 2009 at 10:10 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Re: Textbox disappers due to post back and showed Error:Object reference not set to an in
0
#2 Jun 9th, 2009
Re: Textbox disappers due to post back and showed Error:Object reference not set to a
0
#3 Jun 27th, 2009
your code will never work..
you need to iterate through Gridview rows..
Checking should be done on RowDataBound Event..
you need to iterate through Gridview rows..
Checking should be done on RowDataBound Event..
ASP.NET Syntax (Toggle Plain Text)
foreach(GridviewRows Gvr in Gridview1.rows) { Checkbox chk = (CheckBox)e.row.FindControl("Name Of Your Checkbox"); if(chk.checked == true) { // carry out rest of the operation... } }
Last edited by peter_budo; Jun 27th, 2009 at 11:37 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
![]() |
Similar Threads
- Same old "object reference not set to an instance of an object" problem... (VB.NET)
- I hate the exception "the object reference not set to an instance object",please help (C#)
- Object reference not set to an instance of an object. in a setup Project in ASP.NET (ASP.NET)
- Object reference not set to an instance of an object. (C#)
- value of string is cannot conerted into system.array (VB.NET)
- object reference not set to instance of object+axis2 (Java)
- Object reference not set to an instance of an object. (VB.NET)
- Object reference not set to an instance of an object (ASP.NET)
- sql data pull with no result gives Object reference not set exception (VB.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: code for login control for asp.net using vb
- Next Thread: ASP.NET with C#
| Thread Tools | Search this Thread |
.net 2.0 3.5 ajax alltypeofvideos appliances asp asp.net beginner box browser businesslogiclayer button c# cac checkbox class commonfunctions compatible content contenttype control countryselector courier dataaccesslayer database datagrid datagridview datalist deployment development dgv dialog dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv formview gridview gudi iis javascript list listbox login menu microsoft mouse mssql nameisnotdeclared news novell numerical opera order panelmasterpagebuttoncontrols problem radio ratings redirect registration relationaldatabases reportemail schoolproject search security serializesmo.table sessionvariables silverlight smoobjects software sql sql-server sqlserver2005 ssl tracking treeview validatedate validation vb.net videos vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopment webprogramming webservice wizard xsl






