set the readonly property to textbox in gridview using dropdownlisthttp://forums.asp.net/t/1800978.aspx/1?set+the+readonly+property+to+textbox+in+gridview+using+dropdownlistTue, 08 May 2012 06:07:24 -040018009784969060http://forums.asp.net/p/1800978/4969060.aspx/1?set+the+readonly+property+to+textbox+in+gridview+using+dropdownlistset the readonly property to textbox in gridview using dropdownlist <pre class="prettyprint">protected void Change(object sender, EventArgs e) { GridViewRow row = GridView1.SelectedRow; DropDownList dlMng = (DropDownList)sender; TextBox txtreason = (TextBox)GridView1.SelectedRow.FindControl(&quot;txtreason&quot;); if (dlMng.SelectedIndex == 0) { txtreason.ReadOnly = true; } if (dlMng.SelectedIndex == 1) { txtreason.ReadOnly = false; } }</pre> <p>This is my mycode:</p> <p>In this code i had a error at this line:</p> <pre class="prettyprint"> TextBox txtreason = (TextBox)GridView1.SelectedRow.FindControl("txtreason");</pre> <pre class="prettyprint">The error is:</pre> <h2><i>Object reference not set to an instance of an object.</i></h2> <p><i>any one pls help me...</i></p> 2012-05-07T12:22:57-04:004969073http://forums.asp.net/p/1800978/4969073.aspx/1?Re+set+the+readonly+property+to+textbox+in+gridview+using+dropdownlistRe: set the readonly property to textbox in gridview using dropdownlist <p>Hi</p> <p>The findcontrol couldn't able to find the textbox. Do check whether you are getting Gridview.Selectedrow</p> <p>It should return you GridViewDataRow</p> <p>hope it helps, thanks.</p> <p></p> <p></p> 2012-05-07T12:29:42-04:004969082http://forums.asp.net/p/1800978/4969082.aspx/1?Re+set+the+readonly+property+to+textbox+in+gridview+using+dropdownlistRe: set the readonly property to textbox in gridview using dropdownlist <p>I want to insert bulk from my grid view...</p> <p>Now i deleted seletced row from my code now it shows the same error at 'txtreason'</p> <p>there is any another way?</p> 2012-05-07T12:33:58-04:004969957http://forums.asp.net/p/1800978/4969957.aspx/1?Re+set+the+readonly+property+to+textbox+in+gridview+using+dropdownlistRe: set the readonly property to textbox in gridview using dropdownlist <p>hi</p> <p>Are you trying to get the single row? or you want to loop thru all the rows?</p> <pre class="prettyprint">TextBox txtreason = (TextBox)GridView1.Rows[0].FindControl(&quot;txtreason&quot;);</pre> <pre class="prettyprint"><span class="pun">Try this....Please clarify whether the Dropdown will be avlb for each rows? or on the header</span></pre> <pre class="prettyprint"><span class="pun">thanks.</span></pre> 2012-05-08T04:21:50-04:004969973http://forums.asp.net/p/1800978/4969973.aspx/1?Re+set+the+readonly+property+to+textbox+in+gridview+using+dropdownlistRe: set the readonly property to textbox in gridview using dropdownlist <p>Thanks its working fine for single row where row id is 0, but i need to select individual rows every time why because dropdown is available in each row...&nbsp;</p> <p>for example in my grid i have 10 rows when ever i select 1st row that first row textbox only become readonly...</p> <p>pls help me for this...</p> <p></p> 2012-05-08T04:38:13-04:004970111http://forums.asp.net/p/1800978/4970111.aspx/1?Re+set+the+readonly+property+to+textbox+in+gridview+using+dropdownlistRe: set the readonly property to textbox in gridview using dropdownlist <p>hi</p> <p>I think the onchange event is mapped to your dropdown selectedindex changed?</p> <p>just include this line in the event</p> <pre class="prettyprint">DropDownList ddl = (DropDownList)sender; GridViewRow row = (GridViewRow)ddl.Parent.Parent; int idx = row.RowIndex;</pre> <pre class="prettyprint">Can you check this? hope it helps,thanks</pre> 2012-05-08T05:51:13-04:004970120http://forums.asp.net/p/1800978/4970120.aspx/1?Re+set+the+readonly+property+to+textbox+in+gridview+using+dropdownlistRe: set the readonly property to textbox in gridview using dropdownlist <pre class="prettyprint">protected void Change(object sender, EventArgs e) { DropDownList ddl = (DropDownList)sender; GridViewRow row = (GridViewRow)ddl.Parent.Parent; int idx = row.RowIndex; DropDownList dlMng = (DropDownList)sender; TextBox txtreason = (TextBox)GridView1.Rows[idx].FindControl(&quot;txtreason&quot;); if (dlMng.SelectedIndex == 0) { txtreason.ReadOnly = true; } if (dlMng.SelectedIndex == 1) { txtreason.ReadOnly = false; } }</pre> <pre class="prettyprint"><br /><br /></pre> 2012-05-08T05:54:39-04:004970138http://forums.asp.net/p/1800978/4970138.aspx/1?Re+set+the+readonly+property+to+textbox+in+gridview+using+dropdownlistRe: set the readonly property to textbox in gridview using dropdownlist <p>Try this Code:</p> <pre class="prettyprint">protected void Change(object sender, EventArgs e) { GridViewRow row = GridView1.SelectedRow; DropDownList dlMng = (DropDownList)sender; TextBox txtreason = (TextBox)GridView1.SelectedRow.FindControl(&quot;txtreason&quot;); if (dlMng.SelectedItem = 0) // OR dlMng.SelectedValue = 0 { txtreason.ReadOnly = true; } if (dlMng.SelectedItem = 1) // OR dlMng.SelectedValue = 1 { txtreason.ReadOnly = false; } }</pre> <p><br> <br> </p> 2012-05-08T06:04:25-04:004970139http://forums.asp.net/p/1800978/4970139.aspx/1?Re+set+the+readonly+property+to+textbox+in+gridview+using+dropdownlistRe: set the readonly property to textbox in gridview using dropdownlist <p>Thank you....</p> <p>Its working fine....</p> 2012-05-08T06:04:39-04:004970147http://forums.asp.net/p/1800978/4970147.aspx/1?Re+set+the+readonly+property+to+textbox+in+gridview+using+dropdownlistRe: set the readonly property to textbox in gridview using dropdownlist <p>Which Answer is working Fine? Mark As Answer!&nbsp;</p> 2012-05-08T06:07:24-04:00