Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 datagrid not showing data?

Author  Topic 

jhermiz

3564 Posts

Posted - 2004-10-02 : 10:43:55
I have a data grid I just need to know how to show a value within a row of that grid.

<asp:TemplateColumn HeaderText="Commission">
<HeaderStyle BackColor="White"></HeaderStyle>
<ItemTemplate>
<asp:Label id="lblCommission" runat="server" Text='<% Container.DataItem("CommissionID")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateColumn>

I tried this and nothing shows up for commissionid even though I have the data....

My hyperlink option works fine:

<asp:HyperLinkColumn DataTextField="IssueID" DataNavigateUrlField="IssueID" DataNavigateUrlFormatString="Details.aspx?IssueID={0}"
HeaderText="IssueID"></asp:HyperLinkColumn>

This actually shows the IssueID from the table...

But how do I get values from the db in these itemtemplate labels ?

Also how to control the size of columns on these grids ?

joldham
Wiseass Yak Posting Master

300 Posts

Posted - 2004-10-03 : 10:30:50
Try changing the Text= to

<%# Container.DataItem("CommissionID")%>

Jeremy W. Oldham
Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2004-10-03 : 18:42:01
Yep Jeremy is correct!
In ASP 3.0 it's

<% stuff %>


In ASP.Net it's

<%# stuff %>




<ItemTemplate>
<a href='CustomerDetails.aspx?DashboardCustomerID=<%#DataBinder.Eval(Container.DataItem, "DashboardCustomerID")%>'>
<%#DataBinder.Eval(Container.DataItem, "CustomerName")%>
</a>
</ItemTemplate>


Michael

<Yoda>Use the Search page you must. Find the answer you will.</Yoda>
Go to Top of Page

jhermiz

3564 Posts

Posted - 2004-10-04 : 07:13:22
so what exactly is "Container" or "DataBinder"
?
Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2004-10-04 : 09:48:44
If I recall, Databinder.Eval does some sort of checking to make sure there's no bad data or something along those lines. It was one of those "this is how it's done and I just cut and paste that stuff" type things for me.

Michael

<Yoda>Use the Search page you must. Find the answer you will.</Yoda>
Go to Top of Page
   

- Advertisement -