c# - Inserting Columns to GridView dynamically -


i have gridview page.. added 2 columns!.. didnt want use wizards put data inside looked code on internet talks feeding data dynamically gridview column items..

i added of code if found , modified produce this:

         <columns>      <asp:templatefield headertext="תגובות">       <itemtemplate>           <asp:label id="comments" runat="server" text='<%# getimage(convert.toboolean(databinder.eval(container.dataitem, "ticketreserved"))) %>'></asp:label>         </itemtemplate>                    <itemstyle horizontalalign="right" />        </asp:templatefield>            <asp:templatefield headertext="שם משתמש"><itemtemplate>        <asp:image id="imgbutton" runat="server"              imageurl='<%# getimage(convert.toboolean(databinder.eval(container.dataitem, "ticketreserved"))) %>' ></asp:image>        <br />           <asp:label id="label1" runat="server" text='<%# getimage(convert.toboolean(databinder.eval(container.dataitem, "ticketreserved"))) %>'></asp:label> </itemtemplate>     <headerstyle width="100px" />     <itemstyle width="100px" /> </asp:templatefield>      </columns> 

the function:

 getimage(convert.toboolean(databinder.eval(container.dataitem, "ticketreserved"))) %>  

is dummy function want swap properties code.

here code behind , should do.

    list<controlpanelmessages> allcomments; protected void page_load(object sender, eventargs e) {     allcomments = controlpanelmessages.getallcontrolpanelposts();     foreach (var item in allcomments)     {         name=item.name;         comment=item.comment;         image =resolveurl(item.img);     } }  public string name { get; set; } public string comment { get; set; } public string image { get; set; } 

this method:

controlpanelmessages.getallcontrolpanelposts() 

returns list after sql statements text users name, users avatar , users comment applied.

my question how can insert 3 properties safely instead of

     getimage(convert.toboolean(databinder.eval(container.dataitem, "ticketreserved"))) %>  

i want gridview add items columns till foreach statement ends!!!!

you can put values in datatable , bind datatable gridview.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -