473,327 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

How I assign a value to a textbox depending on the selected value of the dropdownlist

I have a datagridview that has a dropdownlist and textbox. I want to assign a value to a textbox depending on the selected value of the dropdownlist. But I try this getting the error "Object reference not set to an instance of an object". I post my code here:


foreach (GridViewRow gvr in cgvRequest.Rows)
{
//Programmatically access the CheckBox from the TemplateField

//CheckBoxField chk = (CheckBoxField)gvr.FindControl("chkMark");
Label lbl = (Label)gvr.FindControl("lblRequestAmount");

TextBox _txtAmount = (TextBox)cgvRequest.FindControl("txtAmount");

lbl.Text = Convert.ToString(requestinfo.ElementAt(gvr.RowInde x).AmountRequested);

DropDownList ddl = new DropDownList();
ddl = (DropDownList)cgvRequest.FindControl("ddlApprovalT ype");

ddl.SelectedValue = "A";
_txtAmount.Text = lbl.Text;
}


}

Please help.
Dec 26 '11 #1
1 1705
adriancs
122 100+
You may consider to post this question at the ASP section:
http://bytes.com/topic/asp-classic/
Dec 27 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Kannan.M.R | last post by:
Hi, I have a problem in assigning the selected value in the dropdown to a hidden control. It goes like this. I have a repeater control. In the repeater control’s item template, I have a...
5
by: DC Gringo | last post by:
I have a dropdownlist that, upon form submission, I'd like to maintain the selected value when I get my result...how do I do that? <asp:dropdownlist Font-Size="8" id="ddlCommunities"...
6
by: Jenna Alten | last post by:
I have a datagrid with a template column that contains a dropdown list. I currently fill and display the dropdown list on the page load. This is working correctly. I am NOT using an Edit Column. I...
4
by: Chris Kettenbach | last post by:
Good morning all, I am sure this has been asked but I did not see anything. I have a datalist control. In the edititemtemplate I have a dropdownlist. I know on the itemdatabound event is where I...
15
by: sam | last post by:
Hi, I have a bound dropdownlist with an event handler OnSelectedIndexChanged. If I select a value I'm redirected to another page. I come back using the browser's back button, and the option is...
1
by: Ben | last post by:
I have a formview with a few dropdownlists (software version, database version, etc). When a software version is selected, the database version dropdownlist updates itself accordingly. When in...
4
by: Robert Bravery | last post by:
HI all, In JS, how can I change the selected value of a dropdownlist(select options) I know the value of indexed value of the selected value before it is changed. Thanks Robert
1
by: sdshah5 | last post by:
hi, i want to know how to pass selected value from dropdownlist of child page to a multiline textbox on the parent page. in my code it is giving me the "id" of the selected dropdown value in the...
1
by: backups2007 | last post by:
What I need to do is be able to pass a variable that gets assigned as a selected value to a dorp down box. I need to pass it to another page. Please help.
5
by: temijojo | last post by:
Hello, Can someone help me in this problem. In my content page, I used 2 user controls inside an Ajax Toolkit TabControl. One of the user controls is a data entry with a dropdownlist. The...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.