I have When I try to get the value, I always get it first. I think the lists are filled again, but how will it survive? This is my code: codebehind: ListView with
DropDownList Inside I tried both Key: On filling
dropdown list on
OnItemDataBound and
Page_Load on I also tried to check out
postback , but nothing helps.
& lt; Asp: ListView runat ============================================== ======================= "Server" ID = "MyListView" & gt; & Lt; LayoutTemplate & gt; & Lt; Table range = "0" cellpadding = "2" cell area = "0" & gt; & Lt; TR & gt; & Lt; Th & gt; & Lt; ASP: literal runat = "server" text = '& lt;%% resource: resource, labelwise% & gt;' / & Gt; & Lt; / Th & gt; & Lt; Th & gt; & Lt; ASP: literal runat = "server" text = '& lt;%% resource: resource, label import% & gt;' / & Gt; & Lt; / Th & gt; & Lt; Th & gt; & Lt; ASP: literal runat = "server" text = '& lt;%% resource: resource, labeled mode & gt;' / & Gt; & Lt; / Th & gt; & Lt; Th & gt; & Lt; ASP: Little Runat = "Server" text = '& lt;%% Resource: Resource, LabelDate% & gt;' / & Gt; & Lt; / Th & gt; & Lt; Th & gt; & Lt; ASP: Little Runat = "server" text = '& lt;%% resource: resource, labelloadload% & gt; / & Gt; & Lt; / Th & gt; & Lt; / TR & gt; & Lt; Asp: Place holder id = "item placeholder" run = "server" /> & Lt; / Table & gt; & Lt; / LayoutTemplate & gt; & Lt; ItemTemplate & gt; & Lt; TR & gt; & Lt; Td> & Lt;% # DataBinder.Eval (container.detime, "full")%> & Lt; / Td> & Lt; Td> & Lt;% # DataBinder.Eval (container.ditm, "upload")% & gt; & Lt; / Td> & Lt; Td> & Lt;% # DataBinder.Eval (container.datetime, "duration")% & gt; & Lt; / Td> & Lt; TD & gt; & Lt; ASP: DropDownList runat = "server" id = "DaysDropDownList" & gt; & Lt; / ASP: DropDownList & gt; & Lt; / TD & gt; & Lt; Td> & Lt; Asp: FileUpload id = "FileUpload" runat = "server" /> & Lt; / Td> & Lt; / TR & gt; & Lt; / ItemTemplate & gt; & Lt; / ASP: ListView & gt; VAR foreach (MyListView.Items lvItem) {if (lvItem.ItemType == ListViewItemType.DataItem) {DropDownList Dr = lvItem.FindControl ( "DaysDropDownList") as DropDownList; For (i Int = -1; i & gt; = -12; i--) {dr.Items.Add (new ListItem (DateTime.Now.AddMonths (i) .ToString ( "yyyy-MM"), DateTime .Now. AddMonths (i) .string ("yyyy MM")); }}}
protected zero Page_Load (object sender, EventArgs e) {this.Application.DataLayer.LoadData (UserID); This.MyListView.DataSource = this.Application.DataLayer.Data; This.MyListView.DataBind (); LoadDropDownLists (); } Private void LoadDropDownLists () {{foreach (var lvItem in MyListView.Items) if (lvItem.ItemType == ListViewItemType.DataItem) {DropDownList Dr = lvItem.FindControl ( "DaysDropDownList") as DropDownList; Dr.Items.Clear (); For (i Int = -1; i & gt; = -12; i--) {dr.Items.Add (new ListItem (DateTime.Now.AddMonths (i) .ToString ( "yyyy-MM"), DateTime .Now. AddMonths (i) .string ("yyyy MM")); }}}} Public Zero SubmitButtonClick (Object Sender, EventArgs e) {foreach (varLvItem in MyListView.Items) {if (lvItem.ItemType == ListViewItemType.DataItem) {DropDownList dr = lvItem.FindControl ("DaysDropDownList") DropDownList in the form of ; FileUpload fl = lvItem.FindControl ("FileUpload") as FileUpload; If (fl.HasFile) {string filename = UploadFile (fl, dr.SelectedValue); This. Application. data line. Save UploadRod (UserID, 0, (Int.) Upload, upload, Dr. value selected, filename); When you populate your DropdownList with ListItem, you can set the ListItem;}}}}}
Comments
Post a Comment