.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

OnSelectedIndexChanged of the DropDownList in a GridView's PagerTemplate is not fired

Posted By:      Posted Date: October 10, 2010    Points: 0   Category :ASP.Net

Hi, I got information from here quite often.

I just want to share my experience this time and hope it might help someone someday.

I have a DropDownList in my GridView's PagerTemplate.

I used the example code from http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.pagertemplate(VS.80).aspx

I used it in many of my pages. All works fine except one.

The OnSelectedIndexChanged event just isn't fired in that one page.

Later I set the "EnableViewState" of that GridView to false, it works finally.


View Complete Post

More Related Resource Links

How to bind GridView and DropDownList controls using DataTable object

In .net framework 2.0, you can load a DataTable in memory by consuming a data source using a DataReader. In this version you will find the flexibility in accessing the DataReader means write access code once and use again and again using DataReader. To see the functionality of DataTable consider an example that is created using VS2005.

Formview PagerTemplate DropDownList Navigation


Does anyone know if its possible to use a DropDownList within the PagerTemplate to navigate to a specific record?  I have been able to place the DropDownList outside of the FormView and PagerTemplate and make it work, however, I can't get it to work inside the PagerTemplate.


Accessing a row's dropdownlist values AFTER the gridview control is in Edit mode

Hello, I have a gridview control. When it goes into Edit mode, there are 3 dropdownlists in one cell that are populated by separate stored procedures during the RowDataBound event. The 1st dropdownlist's value is used as a parameter to determine what the 2nd dropdownlist is populated with. The 2nd dropdownlist's value is used as a parameter to determine what the 3rd dropdownlist is populated with. Everything works fine when the row is first put into Edit mode. While I'm in Edit mode and I change the selection in the 1st dropdownlist, how do I access the control so I can feed this new parameter to the 2nd dropdownlist? I have the first 2 dropdownlists set for AutoPostBack so that the Page_Load event is fired when the user changes a value. I know how to get access to these controls via the FindControl method when the row is being databound but how do I find the control during the Page_Load event? Thanks for any help!!!   Penny  

Dropdownlist in gridview

hi all,here am posting my code.please solve my problem.problem was...when i trying to add new row in gridview(add button)the items in the dropdownlist was disappering...y it was happening? public partial class New_GeneralComplaints : System.Web.UI.Page { BalCallerTypeMaster bctm = new BalCallerTypeMaster(); BalComplaintMaster bcom = new BalComplaintMaster(); BalOriginMaster bom = new BalOriginMaster(); BalDestinationMaster bdsm = new BalDestinationMaster(); BalPriorityMaster bpm = new BalPriorityMaster(); BalStatus bs = new BalStatus(); BalArticle ba = new BalArticle(); DropDownList dpl1, dpl2, dpl3, dpl4, dpl5; protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { SetInitialRow(); } /* // DropDownList dpl1 = (DropDownList)Gridview1.FindControl("Origin_Station"); DropDownList dpl2 = (DropDownList)Gridview1.FindControl("Delivery_Station"); DropDownList dpl3 = (DropDownList)Gridview1.FindControl("Article_Type");*/ if (!IsPostBack) { DataSet ds1 = bctm.getCallerTypeMaster(); Type_Caller.DataSource = ds1.Tables[0]; Type_Caller.DataTextField = ds1.Tables[0].Columns["Caller_Type_Desc"].ColumnName.ToString(); Type_Caller.DataValueField = ds1.Tables[0].Columns["Caller_Type_ID"].ColumnName.T

Gridview Dropdownlist Databind

Hi All, I am trying to Bind data dropdown list column only inside the gridview  while pageload using asp.net with c#.  I am able to bind the data to it but it is creating rows for total list itmes.  I want to bind to that at the first time i can able to see only one row. Later When i click on any one of the column then it will create a new row. Regards,

Gridview Dropdownlist

Hi, I want to display a dropdownlist inside one cell in my gridview when the user clicks edit. The user should then be able to select an option from the dropdownlist then click update and the selected option will be stored in the cell as text. The gridview is populated using a dataset which is created according to information selected by the user. During the row editing event I remove the textbox control from the cell then add the dropdownlist which is populated from a database table. This displays fine but the dropdown list then can't be found inside the row updating event. Here is a my code: Sub GridView_RowEditing event GridView.EditIndex = e.NewEditIndex   Dim ddl As New DropDownList ddl.ID = "DropDownList1" 'Populate dropdownlist from database GridView.Rows(GridView.EditIndex).Cells(7).Controls.RemoveAt(0) GridView.Rows(GridView.EditIndex).Cells(7).Controls.Add(ddl) End Sub Sub GridView_RowUpdating event Dim row As GridViewRow Dim row2 As DataRow row = CType(GridView.Rows(e.RowIndex), GridViewRow) 'I construct the new row (row2) here and try to find the dropdownlist to get something out of it but throws a null refference exception. row2(6) = CType(row.Cells(7).FindControl("DropDownList1"), DropDownList).Items(0).Text myDataSet.Tables(0).Rows(GridView.EditIndex).Delete() '

Problem Binding DropdownList in a gridView to a datasource

I have a Dropdownlist in an itemTemplate in a gridview. My gridView binds to dataTable1 (from which the selected value for dropdown comes from) and dropDown binds to dataTable2 (i need to get DataValueField and DataTextField from here).<asp:TemplateField HeaderText="Category"> <ItemTemplate> <asp:DropDownList ID="Cat" runat="server" SelectedValue='<%#Bind("CATEGORY") %>' > </asp:DropDownList> </ItemTemplate> <FooterStyle BorderStyle="None" /> <HeaderStyle BorderStyle="None" /> <ItemStyle BorderStyle="None" /> </asp:TemplateField>How do I do that? thanks in advance!

Validating DropdownList Inside Gridview Using Javascript

hi All,      I have Gridview with Dropdownlist which contains data as {select,1,2,3} .Gridview contains multiple rows of data.Submit button is also on form but outside gridview. If any of the rows of gridview dropdownlist contain value as "Select" and click Submit button ,give message as "Please select value". I want to do this stuff using javascript. Thanks in advance.

filter gridview from a dropdownlist with date

having trouble fing any info on what i need to be doing i have tried '{1}'  ,  '#{1}#' , '{1:MM/dd/yyyy}' and a whole bunch of combinations thereof Teh problem is when i get it to actual not have a complie error then the functionality is not correct as i am unable to "select" all from my dropdown list . The only way i have gotten anything close to working is by removinf the % from both the filter and the default value.   here is relevant code   <asp:DropDownList ID="ddlShipDate" AutoPostBack="true" runat="server" Height="16px" Width="75px" DataSourceID="adsPopulateShipDate" DataTextField="dShipDate" DataTextFormatString="{0:MM/dd/yyyy}" DataValueField="dShipDate"> <asp:ListItem Text="All" Value="%"></asp:ListItem> </asp:DropDownList> Pleas enote i removed the append databound items=true<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/JAGENT.mdb" SelectCommand="SELECT [cPronumber], [cCustomerRef], [dShipDate], [cOrigCity], [cOrigState], [dDeliveryDate], [cDestCity], [cDestState] FROM [BillingHistory] WHERE ([cCust

hoq to fill gridview dropdownlist from another db table

Hi, I have a gridview which gets its data from a database table now i ghave added a dropdownlist to this gridview but this dropdown should get the data from another table and should set its value automatically with a foreign key from the  gridview i have added the code like below in my rowDatabound but it just loads 1 field and then how should i get the selectedValue according to the gridview id field?? Protected Sub Friends_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)             If e.Row.RowType = DataControlRowType.DataRow Then                 Dim conn As New SqlConnection(HttpRuntime.Cache("con"))                Dim sql As String = "select ID,ListName from FriendList order by ListName asc"                Dim cmd As New SqlCommand(sql, conn)                cmd.CommandType = CommandType.Text                conn.Open()             &

Assign Value to DropDownList in GridView Dynamically

Hi, I got GridView with 2 columns both are Template field with drop down list. What I need to do is someting like when user select course 3/3A/2A/2B , the type column will auto select pratical option dynamically. When select RTT /FTT/BTT , the type column will select Theory option. Can someone tell me how to work on this thing. Thank you. <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">  <Columns>  <asp:TemplateField HeaderText="Course">  <ItemTemplate>  <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">  <asp:ListItem>2A</asp:ListItem>  <asp:ListItem>2B</asp:ListItem>  <asp:ListItem Value="3">3</asp:ListItem>  <asp:ListItem>3A</asp:ListItem>  <asp:ListItem>BTT</asp:ListItem>  <asp:ListItem>RTT</asp:ListItem>  <asp:ListItem>FTT</asp:ListItem>  <asp:ListItem></asp:ListItem>  </asp:DropDownList>  </ItemTemplate>  </asp:TemplateField>  <asp:TemplateField HeaderText="Type">  <ItemTemplate>  <asp:DropDownList ID="DropDownList2" runat="server">  <asp

dropdownlist in a gridview

can i use dropdownlist in a gridview

dropdownlist controls in gridview issue

 the below code creates drop down each time i add a category to the database table. however, i don't wish to have drop down created each time - how can i have all my data in one drop down? thanks...  <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CascadingDropDownTestConnectionString %>"  SelectCommand="SELECT [CategoryID], [CategoryName] FROM [Category]">  </asp:SqlDataSource>    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="CategoryID"  DataSourceID="SqlDataSource1">  <Columns>  <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" InsertVisible="False"  ReadOnly="True" SortExpression="CategoryID" />  <asp:TemplateField HeaderText="Categories">  <ItemTemplate>  <asp:DropDownList ID="ddlCategories" AutoPostBack="true" DataTextField="CategoryName"  DataValueField="CategoryID" DataSourceID="SqlDataSource1" runat="server" AppendDataBoundItems="true"  SelectedValue='<%# Bind("CategoryID") %>' />  &

Order of the items in a DropDownList inside GridView



I have a DropDownList inside the EditTemplateItem (if the user clicks edit) in a GridView. The DropDownList receives all available rows from the database.

My problem is, if the user clicks Edit in the GridView to edit a row and opens the DropDownList Box the original item is not selected but the first one. That means the items are sorted.

Have someone an idea how I can solve this issue that the right item / the original is selected if I change to edit mode of the grid view?

The only idear that I have is to write some lines in the code behind for the updating event and selected the suitable index manually but I think there must be an easier way.


Gridview Dropdownlist databinding problem


I am using gridview, in ItemTemplate  I am using dropdownlist which has the hard-coded value, I want to get updated value of dropdownlist from database, but whenever I use EVAL, it throws the following error:

 'ddl' has a SelectedValue which is invalid because it does not exist in the list of items.

Parameter name: value

I am using the following code:

<asp:TemplateField HeaderText="Status"  >
                      <asp:DropDownList ID="ddl" runat="server" SelectedValue='<%# Bind("Status")%>' >

Add Dynamically TextBox And DropDownList In Gridview on Button Click Wich is placed outside of Gridv


Hi All,

   I have Gridview and Button Control on Form.i want to Add Dynamically TextBox And DropDownList In Gridview on Button Click Wich is placed outside of Gridview.

When i click on Button -> One TextBox and One Dropdownlist which contains values bydefault 1,2,3 should bind to gridview.    Button is placed outside Gridview.

Thanks in advance.

Dropdownlist inside gridview asp.net



I am creating a gridview with 1 dropdown(Item),1 label(rate),2 Text bob (quantity,total amount).

problem is that dropdown and label access records from one database table.

on the basis of dropdown selection item rate label display rate of that item.

then user insert quantity and amount calculated base of item quantity and rate. and row is autogenerated or by command button for other item.

i am unable to solve this task how can i do this plz help.


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend