How to get selected index of dropdownlistboxs present in two different rows of gridview

I have a gridview, in that i have dropdownlistbox as one column. Without editing the grid view i want to know the selected index of dropdownlistbox for each row.

10/15/2007 12:11:58 PM 91979 articles. 4 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 50

Simply itearte through the Rows collection of your GridView. Then, use the FindControl method of the GridViewRow reference and retrieve a reference to your DropDownList. From here, you can then retrieve your SelectedIndex. This can be done within the GridView.DataBound event or later.

Thanks, Ed

Microsoft MVP - ASP/ASP.NET

10/15/2007 12:30:01 PM

Similar Artilces:

I have a parent and child gridview.  When a button is clicked on the parent  gridview it will open the child gridview and populate it with records based on which row the button was clicked.  What I need to do is get the index of the selected row so that I can then get the DataKeyNames value (as it is a foreign key) in order to populate the child gridview accordingly.  This is what I have come up with, but it doesn't seem to work for me - the e.CommandArguments returns a string with no value, so I get a conversion error when I try to convert it to an int.  If ...

Get Selected row index in gridview
i have this code RowCommand Event from Gridview  protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)  {               int index = ????;         if (e.CommandName.Equals("Select"))         {             Server.Transfer("~/Admin/TampilAnggotaDetail.aspx");         }         else if(e.CommandNa...

How to get the index of the selected row in gridview?
Hi, can anybody tell why this code doesn't work?   <asp:GridView ID="showCompanies" runat="server" DataSourceID=".." DataKeyNames=".." OnRowCommand="showcompanies_RowCommand"><Columns> <asp:ButtonField CommandName="c0" ButtonType="Button" Text="Company" /> ... </Columns> </asp:GridView>   code behind:Sub showcompanies_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs) Dim row As GridViewRow = showCompanies.SelectedRow Dim i As Integer =...

getting selected row index of gridview?
hi how are you .. I want to get the index of selected row of GridView. Such that the page must not be postback. rather after selecting row, i have an button 'Edit' Outside the gridview (i.e. it is not a template item of gridview). this means agter selecting a row on gridview, when i click 'Edit' button, it must get the index of selected row of gridview and then get the Item at that index. how can i do that ?Thanks  From my understanding there is no single "item" at the selected. There is simply a row. You can get that row by:   In your Gridview add an e...

How to get row selected in Gridview and then to get the data from the cells in that Grid?
I have a gridview with about 30 rows of data. If someone selects a row in the grid(Clicking or double clicking) then I want to get the values in each column/cell in that row. Once I get those values, I want to populate other edit controls on my web form with the values selected from the row. So the big question here, is how to capture the row selected from clicking or double clicking. Then how to get the column cell items?   Clickable GridView Row

How to get data from two different tables for two different columns of a gridview based on datakey
Hi All,            I have a Gridview with two different columns- "Faculty" coming from tblFaculty and "Teachers" coming from tblFacultyTeacherLink. I want to get data for "Teachers" by comparing FcaultyId in tblFacultyTeacherLink and then getting Teachers name. How to achieve this without using nested gridviews?  My .aspx Page is as-   <asp:GridView ID="gviewFaculty" DataKeyNames="FacultyId" AutoGenerateColumns="false" runat="server" Width="100%&q...

Get row number/index that a dropdownlist selection was made on (Gridview)
I have a template field that has a dropdownlist in a gridview that has 10 rows. When the user changes the value of any of the dropdownlists i want to be able to find out which row the dropdownlist which was modified is on. I found some code on another site, so if you could help me understand that code or suggest something else that would be great.  Here is the code I found on another site but I get stuck with the last line,----------- THE CODE IN VB-----------  Dim dgi As DataGridItem = CType(ddl.Parent.Parent,DataGridItem) (or ddl.NamingContainer instead of ddl.Parent.Parent) ...

How to get two gridviews in one cell of a row in .net 2.0
Hi I am trying to display two gridviews in a row using datalist.  This is how my code looks <asp:DataList ID="DataList1" runat="server" RepeatDirection="Horizontal" DataKeyField= "GroupID" RepeatColumns="2" OnItemDataBound="DataList1_ItemDataBound">                              <ItemTemplate>              &nb...

To get the row index of selected row in grid view
Hi I have a grid view with a column of checkboxes. if I check a checkbox all the remaining checkboxes should be unchecked except the current one.protected void chkHeadCoach_CheckedChanged(object sender, EventArgs e) {foreach (GridViewRow rowitem in grdv.Rows) {CheckBox chkHeadCoach = (CheckBox)(rowitem.FindControl("chkHeadCoach"));if (chkHeadCoach.Checked) {if(rowitem.RowIndex != //row index of the row I checked now) {chkHeadCoach.Checked = false; } } } how can I get the row index of the row I checked now? }Thanks & Regards,Abhiram Reddy Mekha. AbhiramReddyMekh...

How to get the row index of a selected row in listview control
Can someone please tell me how to get the index of a selected row in a listview.  <ItemTemplate> <asp:LinkButton runat="server" class="linkButton" id="xxxxx" Text='<%#Eval("documenttype") %>' CommandName="OpenFile" CommandArgument='<%#Eval("DocumentKey") %>'></asp:LinkButton></ItemTemplate>what you have to do is, in itemcommand event of ListView, you have to get the value of row indexif(e.CommandName == "corrospondingcommaandname"){     &nb...

Gridview Rows Backcolor getting reset when selecting a row
I have a list of rows in my gridview that list one or more entries per date.  I have coded the RowDataBound event so that all of the rows for a given date have the same backcolor.  Day 1 is white, Day 2 is yellow, Day 3 is white, day 4 is yellow - where each day could have multiple rows.  On each row, I also have an Edit imagebutton that allows each row to be edited via a separate panel and not in-line grid editing.  When I click on the Edit imagebutton, I set the gridviews selectedindex to that row and then using the skin for the grid, the selected row backco...

Getting selected row from gridview
I am trying to create a custom simple gridview control to list all users in a aspnetdb database.  I am populating the gridview with this on the PageLoad event:         Dim Users As New MembershipUserCollection        For Each user As MembershipUser In Membership.GetAllUsers()            Users.Add(user)        Next        gvUserList.DataSource = Users       ...

gridview get selected row
Hi All  How do i get the selected row from the gridview_Rowcommand e.g. If e.CommandName = "Archive" ThenStrItem = GridView1.SelectedRow.Cells(2).Text ' Do something End If thanks Gibbo StrItem = GridView1.Rows(GridView1.SelectedIndex).Cells(2).Text Jos thankyou Sorry, just tried as suggested but get the error Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: index there is definately a value in that column any ideas thanks gibbo   This worked for meDim rowID As Integer = Convert.ToInt32(e.Co...

Web resources about - How to get selected index of dropdownlistboxs present in two different rows of gridview -

Resources last updated: 12/4/2015 4:59:06 PM