473,473 Members | 2,104 Online
Bytes | Software Development & Data Engineering Community
Create 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.
<EditItemTemplate>
<asp:DropDownList ID="FldType_edit" Runat="server" DataSource='<
%#GetFieldType()%>' DataTextField="Type" />
</EditItemTemplate>

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(fldds,"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.WebControls.DataGridCommandEventArgs e)
{
if (e.Item.ItemType == ListItemType.EditItem)
{
DropDownList dd;
dd = (DropDownList)e.Item.FindControl("FieldType_edit") ;
string fldval=dd.SelectedItem.Value;
Response.Write("Field Value is "+ fldval+" ");
}

}
While executing this i am getting the following error:

System.NullReferenceException: 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 2120
On Mar 9, 10:22 am, yasod...@gmail.com wrote:
Hi,
I used a dropdown control bind to a datagrid.
<EditItemTemplate>
<asp:DropDownList ID="FldType_edit" Runat="server" DataSource='<
%#GetFieldType()%>' DataTextField="Type" />
</EditItemTemplate>

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(fldds,"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.WebControls.DataGridCommandEventArgs e)
{
if (e.Item.ItemType == ListItemType.EditItem)
{
DropDownList dd;
dd = (DropDownList)e.Item.FindControl("FieldType_edit") ;
string fldval=dd.SelectedItem.Value;
Response.Write("Field Value is "+ fldval+" ");
}

}

While executing this i am getting the following error:

System.NullReferenceException: 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_edit" != "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.
<EditItemTemplate>
<asp:DropDownList ID="FldType_edit" Runat="server" DataSource='<
%#GetFieldType()%>' DataTextField="Type" />
</EditItemTemplate>
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(fldds,"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.WebControls.DataGridCommandEventArgs e)
{
if (e.Item.ItemType == ListItemType.EditItem)
{
DropDownList dd;
dd = (DropDownList)e.Item.FindControl("FieldType_edit") ;
string fldval=dd.SelectedItem.Value;
Response.Write("Field Value is "+ fldval+" ");
}
}
While executing this i am getting the following error:
System.NullReferenceException: 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_edit" != "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
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....
1
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...
2
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...
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...
2
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...
2
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...
3
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...
6
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...
1
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>...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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 ...
0
muto222
php
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.