Re: How to capture SelectedIndexchanged event of dropdownlist in Datagrid

S

Shiva

Use the OnSelectedIndexChanged attribute of the <asp:DropDownList> element
to hook to your server-side event.

Eg:

In .aspx file:
....
<EditItemTemplate>
<asp:DropDownList id="ddl" runat=server
OnSelectedIndexChanged="SelectionChanged" />
<EditItemTemplate>
....

In code-behind file:

//C#
protected void SelectionChanged (object sender, EventArgs e)
{
DropDownList d = (DropDownList)sender;
// Use d here
}

HTH.

(Type your message here)

--------------------------------
From: Uma Shanmugam

Everyone,
I have a datagrid and it has a dropdownlist in the Edit mode.I want to
capture the selectedIndexChanged event of the dropdownlist. I tried
ItemCommand event and then realised that it is fired when a button is
clicked.Any help will be greatly appreciated.

Thanks in Advance
Uma Shanmugam
 
G

Guest

Hi Shiva,

Yes, selectchanged is captured. But the SelectedItemIndex still remain
without change. Any Idea?

Yuki
 
J

Jc Morin

Did you assign the value in the Page_Load event ? maybe you didn't set the
routine in

if (!IsPostBack) {

}

so after postback the original value is re-apply before you read the value
again...
 
Joined
Jun 14, 2012
Messages
1
Reaction score
0
did u set the autopostback to true ??


<asp:DropDownList ID="ddlProductType" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlProductType_SelectedIndexChanged">
</asp:DropDownList>





Did you assign the value in the Page_Load event ? maybe you didn't set the
routine in

if (!IsPostBack) {

}

so after postback the original value is re-apply before you read the value
again...

--------------------------
Jean-Claude Morin, MCP
Software Developer
2k1Soft/kCentric, Canada


"Yuki" <[email protected]> wrote in message
news:[email protected]...
> Hi Shiva,
>
> Yes, selectchanged is captured. But the SelectedItemIndex still remain
> without change. Any Idea?
>
> Yuki
>
> "Shiva" wrote:
>
> > Use the OnSelectedIndexChanged attribute of the <asp:DropDownList>

element
> > to hook to your server-side event.
> >
> > Eg:
> >
> > In .aspx file:
> > ....
> > <EditItemTemplate>
> > <asp:DropDownList id="ddl" runat=server
> > OnSelectedIndexChanged="SelectionChanged" />
> > <EditItemTemplate>
> > ....
> >
> > In code-behind file:
> >
> > //C#
> > protected void SelectionChanged (object sender, EventArgs e)
> > {
> > DropDownList d = (DropDownList)sender;
> > // Use d here
> > }
> >
> > HTH.
> >
> > "Uma Shanmugam via .NET 247" <[email protected]> wrote in message
> > news:[email protected]...
> > (Type your message here)
> >
> > --------------------------------
> > From: Uma Shanmugam
> >
> > Everyone,
> > I have a datagrid and it has a dropdownlist in the Edit mode.I want to
> > capture the selectedIndexChanged event of the dropdownlist. I tried
> > ItemCommand event and then realised that it is fired when a button is
> > clicked.Any help will be greatly appreciated.
> >
> > Thanks in Advance
> > Uma Shanmugam
> >
> > -----------------------
> > Posted by a user from .NET 247 (http://www.dotnet247.com/)
> >
> > <Id>/ZIKIJ+ZZkqlTW/OJYF/Cg==</Id>
> >
> >
> >
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top