I can not convert my selected index to the fire from my dropdown list. I have the following:
& lt; Form id = "form1" runat = "server" & gt; & Lt; Div & gt; & Lt; Asp: GridView id = "grdPoll" runat = "server" auto generated column = "wrong" & gt; & Lt; Columns & gt; & Lt; ASP: TemplateField & gt; & Lt; ItemTemplate & gt; & Lt; ASP: Dropdown List ID = "Dropdown List 1" Runat = "Server" AutoPostback = "True" On-Selected Indices Changed = "Dropdown List 1 Select Indies Change" & gt; & Lt; Asp: ListItem text = "review" value = "review" selected = "true" & gt; Review & lt; / Asp: ListItem & gt; & Lt; Asp: ListItem text = "Level1" value = "lvl1" & gt; Send back to level 1 & lt; / Asp: ListItem & gt; & Lt; / ASP: DropDownList & gt; & Lt; / ItemTemplate & gt; & Lt; / ASP: TemplateField & gt; & Lt; / Column & gt; & Lt; / ASP: GridView & gt; & Lt; Asp: Label ID = "lblCity" runat = "server" text = "label" & gt; & Lt; / Asp: Label & gt; & Lt; / Div & gt; & Lt; / Form & gt;
I have the code in my possession:
Secure zero empty drop down list 1 selected indexed (object sender, event date e) {this.lblCity. Text = (DropDownList Sender) .SelectedValue; }
If I put this same DDL outside of Gridview, then it sets a fire.
The postback is happening and the autopost is set to the correct event never fire. Why can I fire my incident from within Gridview?
Thank you.
Well, this question was asked a month ago and can now be irrelevant, but @ LFSR Recently it was enough to edit, this is in the "active question" list.
Since it is unanswered (224 views!), I thought I should go to:
The problem is that in the context of any grid view, dropdownist (later Referred to as DDL) is a dynamic control and therefore its incidents are to be reposted on postback.
When this concept is understood, the solution is relatively simple:
ASPX:
& asp: dropdown List ID = "DDL1" runat = "server" autostebback = "true" on-select index change = "DDL1 select Indies switched" & gt; & Lt; Asp: ListItem text = "review" value = "review" selected = "true" & gt; Review & lt; / Asp: ListItem & gt; & Lt; Asp: ListItem text = "Level1" value = "lvl1" & gt; Send back to level 1 & lt; / Asp: ListItem & gt; & Lt; / ASP: DropDownList & gt;
cs code:
protected zero page_load (object sender, event aRGS) {if (! Page.IsPostBack) {// Bind the gridwatch in something . DataBindGrid (); }} Secure void converted to DDL1 selected index (object sender, eventArgse E) {this.lblCity.Text = (dropdown list sender). Selected value; } Zero grdPoll_RowDataBound (object sender, GridViewRowEventArgs e) protected {if (Page.IsPostBack) {if (e.Row.RowType == DataControlRowType.DataRow) {DropDownList DDL = e.Row.FindControl ("DDL1") as DropDownList ; If (! DDL = null) {ddl.SelectedIndexChanged + = new eventhandler (DDL1_SelectedIndexChanged); }}}}
Comments
Post a Comment