473,406 Members | 2,620 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,406 software developers and data experts.

GridView Edit DropDownList Selected - .Net 2.0

I have a gridview in .net 2.0 with a dropdownlist of two items - that being "active" and "inactive".

<EditItemTemplate> <asp:DropDownList ID="ddlStatus" runat="server" AutoPostBack="true">
<asp:ListItem Text="active" Value="active"></asp:ListItem>
<asp:ListItem Text="inactive" Value="inactive"></asp:ListItem
</asp:DropDownList>
</EditItemTemplate>

I also have AutoGenerateEditButton="true" AutoGenerateDeleteButton="true".
So when I run the application and click the edit button on a row I get the values for the other fields in textboxes as I expect, but for the dropdownlist, I get the two values in a dropdown, but the one that was chosen for that row already is NOT showing as the first one (selected).

With asp.net 1.1 I used the ItemDataBound event to handle getting the selected value for each dropdownlist when being displayed in edit. The ItemDataBound event is no longer available for this "new" datagrid know as the gridview.

How can I capture the current value of a row's dropdownlist as the selected one in that list and in what event can this be done?
May 22 '07 #1
1 13563
I have a gridview in .net 2.0 with a dropdownlist of two items - that being "active" and "inactive".

<EditItemTemplate> <asp:DropDownList ID="ddlStatus" runat="server" AutoPostBack="true">
<asp:ListItem Text="active" Value="active"></asp:ListItem>
<asp:ListItem Text="inactive" Value="inactive"></asp:ListItem
</asp:DropDownList>
</EditItemTemplate>

I also have AutoGenerateEditButton="true" AutoGenerateDeleteButton="true".
So when I run the application and click the edit button on a row I get the values for the other fields in textboxes as I expect, but for the dropdownlist, I get the two values in a dropdown, but the one that was chosen for that row already is NOT showing as the first one (selected).

With asp.net 1.1 I used the ItemDataBound event to handle getting the selected value for each dropdownlist when being displayed in edit. The ItemDataBound event is no longer available for this "new" datagrid know as the gridview.

How can I capture the current value of a row's dropdownlist as the selected one in that list and in what event can this be done?
Solution:
The RowDataBound handler was not executing, so I added:
OnRowDataBound="gv2_RowDataBound" to the gridview control.
I could address the dropdownlist (edititemtemplate) when in the RowDataBound event handler, I had a RowState of Edit...

if (e.Row.RowState == DataControlRowState.Edit)
{
DropDownList ddStatus = (DropDownList)e.Row.FindControl("ddlStatus");
ddStatus.SelectedValue = stat;
}
May 22 '07 #2

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

Similar topics

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...
1
by: ken | last post by:
I added a CustomValidator in Gridview edit mode, how to set the cusomvalidator to invalid or valid when check the update
1
by: rockdale | last post by:
Hi, all Is there a way to dynamically attach a regularexpressionvalidator to a textbox base on dropdownlist selected item? Let's say I have a dropdownlist list all contact type - phone, cell,...
1
by: SubashiniKumaar | last post by:
how to copy dropdownlist selected items to another dropdownlist in Asp.net using C# codings
2
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, i'm in a gridview edit row that has a DropDownList in one column and a status Label in the 2nd column. When i changed the value in the dropdownlist, there's a client-side javascirpt...
1
by: Lakshmi GagniShetty | last post by:
In gridview edit event it is possible to display dropdownlist instead of text boxes.I am using dotnet 2005. Here the gridview autogenerate columns are false. And I had only one row and columns...
1
by: arunbojan | last post by:
Hi All, I have an editable datagrid with 10 columns, one of those is ddl column which I used for showing the status.... By default all the columns are readonly, when user clicks edit,...
1
by: anithaapr05 | last post by:
Dear All How to edit DropDownList in asp.net Thanks Anitha
3
by: Shashirk | last post by:
I have a Maniform with a sub form attached to it, when ever people enter the data and save, all the records in the sub form with turn to "Allowedits = False" – This is the code that has been given on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
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...

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.