asp.net - Accessing listview itemtemplate from codebehind -
I'm hoping to dynamically change the number of columns in my ItemView in my ListView: < Pre> Then I got the code behind it: There may be another way to go about this, but This is the only idea so far. Asp.net newbie, any advice, is very welcome! Thanks! The syntax may not be correct, but try to reverse something like this in your code: & lt; Asp: ListView runat = "server" id = "report listview" datasource id = "Reportist VJSDS" & gt; & Lt; LayoutTemplate & gt; & Lt; Table & gt; & Lt; TR & gt; & Lt; Asp: placeholder runat = "server" id = "itemplay" /> & Lt; / TR & gt; & Lt; / Table & gt; & Lt; / LayoutTemplate & gt; & Lt; ItemTemplate & gt; & Lt ;! - Select COMMAND, depending on the selection statement, the number of columns in the rear code needs to be dynamic - & gt; & Lt; / ItemTemplate & gt; & Lt; / ASP: ListView & gt;
protected sub page_Load (ByVal as the object, byVal E. System.EventArgs ) Handles me On the basis of load 'sent request.Form variables, select the X number of columns':' SqlStatement = Select "For each Request.Form values" "From Employees" Example: "Select FName 'Run SQL command' works by all the Lname, Email, Phone Staff, now the question is how will I change the item 'Times' template so that it has the correct number column. Pseudo code) for each line ("& lt; tr & Gt; ") for each Request.Form as I reportLIstView.ItemTemplate.Add (" & lt; TD & gt; "sqlresult: something like this (i) & amp;" & lt; / td & gt; ") Next ReportListView.ItemTemplate.Add (" & lt; / tr & gt; ") Next End Sub
& lt; Table & gt; & Lt; Asp: ListView id = "ListView1" runat = "server" & gt; & Lt; ItemTemplate & gt; & Lt; TR & gt; & Lt; Asp: Place Holder ID = "Place Holder 1" Runat = "Server" /> & Lt; / TR & gt; & Lt; / ItemTemplate & gt; & Lt; / ASP: ListView & gt; & Lt; / Table & gt;
PLC in each item Request.Form plc.Controls.Add string (New verb (String.Format ("as & lt) as
placeholder = DirectCast (listItem.FindControl (" Placeholder 1 "), placeholder) Then nothing isnot for, TD> {0} & lt; / td> ", item))) Next End if Next
Comments
Post a Comment