473,851 Members | 2,236 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with retrieving the selected value in a dropdown list

Hi,
I used a dropdown control bind to a datagrid.
<EditItemTempla te>
<asp:DropDownLi st ID="FldType_edi t" Runat="server" DataSource='<
%#GetFieldType( )%>' DataTextField=" Type" />
</EditItemTemplat e>

The values for the datagrid are retrieved from the database using the
GetFieldType function
public DataSet GetFieldType()
{
SqlDataAdapter fldad = new SqlDataAdapter( "SELECT
Type
FROM FieldType Order by FID", myConnection);
DataSet fldds = new DataSet();
fldad.Fill(fldd s,"FieldType" );
return fldds;

}
Then i try to retrieve the selected the values in the database. i
thought of doing this in the update command event.

public void DataGrid_Fields _UpdateCommand( object source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs e)
{
if (e.Item.ItemTyp e == ListItemType.Ed itItem)
{
DropDownList dd;
dd = (DropDownList)e .Item.FindContr ol("FieldType_e dit");
string fldval=dd.Selec tedItem.Value;
Response.Write( "Field Value is "+ fldval+" ");
}

}
While executing this i am getting the following error:

System.NullRefe renceException: Object reference not set to an
instance
of an object.
While debugging, i found the value of dd is "Unexpected value". The
value is not assigned for dd. Kindly help me to come out from that.
Thanks & Regards,
Yasodhai

Mar 9 '07 #1
2 2133
On Mar 9, 10:22 am, yasod...@gmail. com wrote:
Hi,
I used a dropdown control bind to a datagrid.
<EditItemTempla te>
<asp:DropDownLi st ID="FldType_edi t" Runat="server" DataSource='<
%#GetFieldType( )%>' DataTextField=" Type" />
</EditItemTemplat e>

The values for the datagrid are retrieved from the database using the
GetFieldType function

public DataSet GetFieldType()
{
SqlDataAdapter fldad = new SqlDataAdapter( "SELECT
Type
FROM FieldType Order by FID", myConnection);
DataSet fldds = new DataSet();
fldad.Fill(fldd s,"FieldType" );
return fldds;

}

Then i try to retrieve the selected the values in the database. i
thought of doing this in the update command event.

public void DataGrid_Fields _UpdateCommand( object source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs e)
{
if (e.Item.ItemTyp e == ListItemType.Ed itItem)
{
DropDownList dd;
dd = (DropDownList)e .Item.FindContr ol("FieldType_e dit");
string fldval=dd.Selec tedItem.Value;
Response.Write( "Field Value is "+ fldval+" ");
}

}

While executing this i am getting the following error:

System.NullRefe renceException: Object reference not set to an
instance
of an object.

While debugging, i found the value of dd is "Unexpected value". The
value is not assigned for dd. Kindly help me to come out from that.

Thanks & Regards,
Yasodhai
"FldType_ed it" != "FieldType_edit "

You named your control as FldType_edit

Mar 9 '07 #2
ok. Thanks a lot.

Regards,
Yasodhai

On Mar 9, 5:49 pm, "Alexey Smirnov" <alexey.smir... @gmail.comwrote :
On Mar 9, 10:22 am, yasod...@gmail. com wrote:


Hi,
I used a dropdown control bind to a datagrid.
<EditItemTempla te>
<asp:DropDownLi st ID="FldType_edi t" Runat="server" DataSource='<
%#GetFieldType( )%>' DataTextField=" Type" />
</EditItemTemplat e>
The values for the datagrid are retrieved from the database using the
GetFieldType function
public DataSet GetFieldType()
{
SqlDataAdapter fldad = new SqlDataAdapter( "SELECT
Type
FROM FieldType Order by FID", myConnection);
DataSet fldds = new DataSet();
fldad.Fill(fldd s,"FieldType" );
return fldds;
}
Then i try to retrieve the selected the values in the database. i
thought of doing this in the update command event.
public void DataGrid_Fields _UpdateCommand( object source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs e)
{
if (e.Item.ItemTyp e == ListItemType.Ed itItem)
{
DropDownList dd;
dd = (DropDownList)e .Item.FindContr ol("FieldType_e dit");
string fldval=dd.Selec tedItem.Value;
Response.Write( "Field Value is "+ fldval+" ");
}
}
While executing this i am getting the following error:
System.NullRefe renceException: Object reference not set to an
instance
of an object.
While debugging, i found the value of dd is "Unexpected value". The
value is not assigned for dd. Kindly help me to come out from that.
Thanks & Regards,
Yasodhai

"FldType_ed it" != "FieldType_edit "

You named your control as FldType_edit- Hide quoted text -

- Show quoted text -

Mar 9 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
10844
by: Kris Rockwell | last post by:
Hello (again), I have gotten the dropdown list functionality to work through a few tricks (probably not the most efficient, but it works) but I am not sure how to set the default selected value. I have tried setting various values to represent the default value with little success. Essentially I am looking to have the first item in the list be the default selected item. I noticed in the properties for a dtat grid you could set a default...
1
2317
by: Norm Katz | last post by:
When you use a bound combobox and you set its dropdown style to "dropdown" that allows you to enter text in the edit box. But if you enter anything other than a value in the current bound items collection, the .text property does not update. Furthermore, you can't easily trap an event to examine the new value if your program assigns it programmatically as opposed to someone typing it in and tabbing away from it. That is, TextChanged does...
2
4559
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was set to...it is set to false. Can someone show me what I am doing wrong and tell me the correct way? Thank you. In the page load event, I am doing the following:
1
10404
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 edit mode, everything works fine - the selected value in each list defaults to the value from the database record (selectedvalue=bind...). However, in insert mode (insertitem), it is not working. I pass in a value on the query string that I would...
2
1638
by: echan8 | last post by:
I have a dropdown list in a datagrid which I am dynamically adding items to with JavaScript. When I try to access the value of the dropdown list on postback, there is no value. The value is null. I get the feeling I'm supposed to do something else, but I'm not sure what. If anyone can help, I would appriciate it. Thanks. foreach( DataGridItem di in DataGrid1.Items )
2
1238
by: sameer | last post by:
Hi guys, thanks in advance. trying to implement some multithreading here : VS 2003 VB.net winforms I have a dropdown on a form which has list of vendors, when the user selects a vendor from this dropdown, a new thread is created which calls a webservice and the webservice returns the list of cities the vendor is in and this data
3
3530
by: er1 | last post by:
Hi all, I have created a double dropdown list. Based on the first list selection, second list populates (this works fine). I have a submit button, which when clicked should run a select query based on the values selected on both the dropdown lists. But this part is not working. It picks up right value for the first dropdown list and always takes the FIRST value of the second dropdown list. I am not sure how to make it use the selected value...
6
5862
by: yasodhai | last post by:
Hi, I used a dropdown control which is binded to a datagrid control. I passed the values to the dropdownlist from the database using a function as follows in the aspx itself. <asp:DropDownList ID="FldType_add" Runat="server" DataSource='< %#GetFieldType()%>' DataValueField="Type" DataTextField="Type" /> Oce the page is loaded all the values are added to the dropdown list. But when I thought of getting the selected value from the...
1
1490
by: gauravtechie | last post by:
Hi all, I have a javascript that is reloading itself on every menu change, Now the problem is that the values of the product doesn`t reset itself on catalogue change, the code is <html> <head> <title></title>
0
9898
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11020
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10670
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10356
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9506
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7907
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5736
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4549
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4143
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.