Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I want my datagrid to display my dataset in the following way:

 

Note Added Date By Who Action

 

14/01/2004 9:07:29 AM George Robinson Quote

Comments go here

 

13/01/2004 4:23:24 PM George Robinson Installation

More comments go here

 

13/01/2004 4:23:20 PM George Robinson Installation

Even more comments go here

 

 

Thing is, i'm quite new and I'm having little success. Basically I want the first three column items in the row header and the last one, the description in the main body, as above.

 

Heres my code

 

HTML

 

<asp:datagrid id="NoteGrid_GRD" style="Z-INDEX: 104; LEFT: -1px; POSITION: absolute; TOP: 422px" runat="server" CellPadding="3" BorderWidth="1px" BorderStyle="None" BorderColor="#E7E7FF" GridLines="Horizontal" BackColor="White" OnItemDataBound="NoteGrid_GRD_ItemDataBound" AutoGenerateColumns="False">

<SelectedItemStyle Font-Bold="True" ForeColor="#F7F7F7" BackColor="#738A9C"></SelectedItemStyle>

<AlternatingItemStyle BackColor="#F7F7F7"></AlternatingItemStyle>

<ItemStyle ForeColor="#4A3C8C" BackColor="#E7E7FF"></ItemStyle>

<HeaderStyle Font-Bold="True" ForeColor="#F7F7F7" BackColor="#4A3C8C"></HeaderStyle>

<FooterStyle ForeColor="#4A3C8C" BackColor="#B5C7DE"></FooterStyle>

<Columns>

<asp:BoundColumn DataField="Date" HeaderText="Note Added Date"></asp:BoundColumn>

<asp:BoundColumn DataField="ByWho" HeaderText="By Who"></asp:BoundColumn>

<asp:BoundColumn DataField="FK_Action_Performed" HeaderText="Action"></asp:BoundColumn>

<asp:BoundColumn DataField="Note_Description"></asp:BoundColumn>

</Columns>

<PagerStyle HorizontalAlign="Right" ForeColor="#4A3C8C" BackColor="#E7E7FF" Mode="NumericPages"></PagerStyle>

</asp:datagrid>

 

And my Code Behind

 

noteView = noteData.Tables[NotesData.NOTES_TABLE].DefaultView;

NoteGrid_GRD.DataSource = noteView;

NoteGrid_GRD.DataBind();

 

public void NoteGrid_GRD_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)

{

if(e.Item.ItemType == ListItemType.Header)

{

e.Item.Cells[3].ColumnSpan = 2;

e.Item.Cells.RemoveAt(4); //The error above is thrown because of this

 

}

}

 

Any help would be much appreciated!!

Posted

I'm very interested in this thread at the moment. I'm currently in a proof of concept stage for a internal ASP.NET application that displays invoices. We'd like to make the grid editable, maybe even a bit like SQL Server, where the bottom row is blank and you start typing in it to add another row.

 

Eventually we'll be integrating with Biztalk 2004 and all this XML stuff, but whatr should I be using for this? Whats you recommendation? What ARE the differences between the Datagrid and the DataList? Are there others that are suitable for this sort of functionality?

  • 2 weeks later...
Posted

Dont use a boundcolumn, you would use a templatecolumn instead.

 

<Columns>

<asp:TemplateColumn HeaderText="Information">

<ItemTemplate><%# Databinder.Eval(Container.DataItem,"Date")%> <%# Databinder.Eval(Container.DataItem,"ByWho")%> <%# Databinder.Eval(Container.DataItem,"FK_Action_Performed")%><br>

<%# Databinder.Eval(Container.DataItem,"Note_Description")%>

</ItemTemplate>

</asp:TemplateColumn>

</Columns>

  • Moderators
Posted
dsigns, Binding executes faster than using the methods you posted above. If you're using a control that is not included in the datagrid/list than yes it makes sense, otherwise I cannot agree your method.
Visit...Bassic Software
Posted
I was under the impression he was looking for format his datagrid in the specific way he listed it above. If that's the case, then the way I stated will work.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...