Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Drop down list on each GridView row

Reply
Thread Tools

Drop down list on each GridView row

 
 
McGeeky
Guest
Posts: n/a
 
      09-22-2007
Hi. I have a read only GridView. For each row I want to display a drop down
list which contains a list of actions the user can select from for that
particular row. E.g. "view details". When they select an action in the drop
down list I want to do a post back. How will I know which row they made the
selection in?

Is there a way to embed the row Id in the drop down list so it gets sent
back to the server?

Thanks


 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      09-23-2007
Hi,

you don't need the row ID. Instead handle DropDownList's
SelectedIndexChanged event and in that get reference to the DropDownList
raising the event, you'd get that via sender argument (first argument to the
event handling method)

[VB.NET]
Dim ddl As DropDownList = CType(sender, DropDownList)

[C#]
DropDownList ddl = (DropDownList)sender;

Then trick is to know how databound controls work. The GridViewRow is naming
container of your DropDownList

[VB.NET]
Dim row As GridViewRow = CType(ddl.NamingContainer, GridViewRow)

[C#]
GridViewRow row = (GridViewRow)ddl.NamingContainer;

I've explained some background for this type of scenarios:

Understanding the naming container hierarchy of ASP.NET databound controls
http://aspadvice.com/blogs/joteke/ar...-controls.aspx

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net



"McGeeky" <(E-Mail Removed)> wrote in message
news:%23Z%23VDFQ$(E-Mail Removed)...
> Hi. I have a read only GridView. For each row I want to display a drop
> down list which contains a list of actions the user can select from for
> that particular row. E.g. "view details". When they select an action in
> the drop down list I want to do a post back. How will I know which row
> they made the selection in?
>
> Is there a way to embed the row Id in the drop down list so it gets sent
> back to the server?
>
> Thanks
>



 
Reply With Quote
 
 
 
 
McGeeky
Guest
Posts: n/a
 
      09-23-2007
Cool. Thanks so much for that!!

"Teemu Keiski" <(E-Mail Removed)> wrote in message
news:uGt2I6a$(E-Mail Removed)...
> Hi,
>
> you don't need the row ID. Instead handle DropDownList's
> SelectedIndexChanged event and in that get reference to the DropDownList
> raising the event, you'd get that via sender argument (first argument to
> the event handling method)
>
> [VB.NET]
> Dim ddl As DropDownList = CType(sender, DropDownList)
>
> [C#]
> DropDownList ddl = (DropDownList)sender;
>
> Then trick is to know how databound controls work. The GridViewRow is
> naming container of your DropDownList
>
> [VB.NET]
> Dim row As GridViewRow = CType(ddl.NamingContainer, GridViewRow)
>
> [C#]
> GridViewRow row = (GridViewRow)ddl.NamingContainer;
>
> I've explained some background for this type of scenarios:
>
> Understanding the naming container hierarchy of ASP.NET databound controls
> http://aspadvice.com/blogs/joteke/ar...-controls.aspx
>
> --
> Teemu Keiski
> AspInsider, ASP.NET MVP
> http://blogs.aspadvice.com/joteke
> http://teemukeiski.net
>
>
>
> "McGeeky" <(E-Mail Removed)> wrote in message
> news:%23Z%23VDFQ$(E-Mail Removed)...
>> Hi. I have a read only GridView. For each row I want to display a drop
>> down list which contains a list of actions the user can select from for
>> that particular row. E.g. "view details". When they select an action in
>> the drop down list I want to do a post back. How will I know which row
>> they made the selection in?
>>
>> Is there a way to embed the row Id in the drop down list so it gets sent
>> back to the server?
>>
>> Thanks
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Gridview: embedding a texbox and button in each row, passing info from that row to a function? Ken Fine ASP .Net 4 07-14-2008 07:51 AM
retrive preselected value in second drop down list from the first drop down list weiwei ASP .Net 0 01-05-2007 07:29 PM
Auto Drop down a Drop Down List xxbmichae1@supergambler.com Javascript 5 11-23-2005 01:35 AM
ok I can do a totals row but how about a percentage row after each data row D ASP .Net Datagrid Control 0 05-23-2005 04:10 PM
New to .NET, can I have one drop down box control the data of another drop down box using a database? SirPoonga ASP .Net 2 01-07-2005 10:44 PM



Advertisments