Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > Databound a Stringarray to gridview...
 

Databound a Stringarray to gridview...

Hi all,

I have a simple question:

how can I bound the data in a string[] to a gridview?

the string[] list has 1 collumn and I just want to databound the items (for ex.: 3 dimensions, so 3 items) to a simple gridview...

with the code bellow I allready see how many rows that wil be displayed...

this is my starting code:

string[] lijst;

lijst = strFiles.Split('$');

GridView1.DataSource = lijst;

GridView1.DataBind();

and the startingcode on the webform:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="524px">

<Columns>

<asp:ButtonField ButtonType="Button" CommandName="Edit" HeaderText="resend" ShowHeader="True"

Text="resend">

<ControlStyle CssClass="plaintxt" Width="50px" />

<FooterStyle BorderWidth="50px" />

</asp:ButtonField>

<asp:TemplateField HeaderText="files">

<ItemTemplate>

<asp:Label Text="DataItem. COntainer" runat="server" ID="fg"></asp:Label>

</ItemTemplate>

</asp:TemplateField>

</Columns>

</asp:GridView>

thanks in advanced...

BNassen  Wednesday, April 25, 2007 12:47 PM

Try:

<asp:Label Text='<%# Container.DataItem %>' runat="server" ID="fg" />

jgalley  Wednesday, April 25, 2007 4:36 PM

Try:

<asp:Label Text='<%# Container.DataItem %>' runat="server" ID="fg" />

jgalley  Wednesday, April 25, 2007 4:36 PM

thank you very much, that works just fine...

allthough I found the answer to my question myself

greeeetzzzz

BNassen  Thursday, April 26, 2007 6:12 AM

You can use google to search for other answers

Custom Search

More Threads

• CheckBox Column in DataGridView, shift-click functionality
• working with DataGridViewCheckBoxCell
• Binding an ErrorProvider to an object with child objects
• windows forms & asp membership login
• Updating a specific row in a column
• [c#]datagridview - prevent and replace char in cells
• Ms Access Error while inserting the record
• Master/Detail Grid with relation not showing new record
• Populating datagridview in C#
• Insert a Column into a dataGridView?