Domanda

I have the code

 <asp:DataList ID="DataList1" runat="server" 
       DataKeyField="TextId" OnEditCommand="DataList1_EditCommand"
       OnCancelCommand="DataList1_CancelCommand" 
       OnDeleteCommand="DataList1_DeleteCommand" 
       OnUpdateCommand="DataList1_UpdateCommand">
     <EditItemTemplate>
         <asp:TextBox Runat="server" ID="TheNotes"
             Text='<%# Bind("notes") %>' />
     </EditItemTemplate>
 </asp:DataList>

What i want to do is bind 2 variables to one control

  <asp:TextBox Runat="server" ID="TheNotes"
     Text='<%# Bind("notes") Bind("dates")  %>' />

Anyone know how to do this ? without it erroring, they are both in the control datasource

È stato utile?

Soluzione

You can do it by using the below 3 solutions

Solution 1 :

<asp:TextBox Runat="server" ID="TheNotes"
     Text='<%# Bind("notes") + Bind("dates")  %>' />

Solution 2 :

You can do one more things, u can select two column as a single column in sql select query.

SELECT (ColumnA + ColumnB) AS ColumnZ
FROM Table;

and then bind it with single control

Solution 3:

bind multiple data to itemtemplate in gridview using Row data bound

And

using string format

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top