Hi Greg,

I have tried this approach the only thing is that when I want to 
suppress the rows if I have a table cell or a <br> tag around the 
dataitem this is still rendered to the screen, thus causing 
formatting problems. Is there a way that I can have a function call 
to create <br> when a dataitem is present in the results?

Sean


--- In [EMAIL PROTECTED], "Greg Ewing" 
<[EMAIL PROTECTED]> wrote:
> Sean, you should try to use the ItemDataBound event and put your 
conditional
> code in there based on e.Item, the item currently bound.  You can 
find
> samples up at www.datagridgirl.com.
> 
> Greg
> 
> -----Original Message-----
> From: sean12302000 [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, July 01, 2004 3:22 AM
> To: [EMAIL PROTECTED]
> Subject: [AspNetAnyQuestionIsOk] condtional formattting in ado .net
> 
> Hi There,
> 
> I am trying to make the transition from asp .asp .net, I have been 
> trying to format data based on different conditions without much 
luck.
> 
> I have 3 datagrids, the first one displays an image, the second one 
> displays columns from the database that are common (or appear 
> everytime the stored procedure is executed. 
> 
> The third datagrid which I am trying to make work is based on 
> different condtions
> 1. the value of (strDec) is a form name and I need to be able to 
> format the results based on this name, there is only one row 
returned 
> but there are multiple columns so are null and some are not I need 
to 
> omit the null ones.
> 2. I tried to use if then else but this does not work, some of the 
> forms have 3 columns next to each other and to achieve this I tried 
> to create a table control at runtime but I could only create it in 
a 
> loop I keept getting syntax errors when I tried to access each 
column 
> individually.
> 
> I just want to be able to have the flexability to creat something 
> like this:
> 
> Please help - thank in advance for your answer - Sean
> 
> if strdec =1 AND colvalue NOT NULL then
> <table>
> <tr><td>value1</td><td>value1</td></tr>
> <tr><td>&nbsp;</td><td>value1</td></tr>
> <td>value1</td><td>&nbsp;</td></tr>
> Elseif strdec =2 colvalue NOT NULL then
> <tr><td>value1</td><td>value1</td></tr>
> <tr><td>&nbsp;</td><td>value1</td></tr>
> End if 
> 
> 
> 
> 
> Public Function ShowData(ByVal strDec as string, ByVal strImageID 
as 
> Integer)
> Dim myCommand As SqlCommand
> Dim colName As DataColumn
> Dim dRow As DataRow
> 
> 
> Dim da as New SQLDataAdapter()
> Dim dt As  New DataTable
> Dim dtNew As DataTable
> Dim strName as string
>  
>               Dim myConnection As SqlConnection = New SqlConnection
> (ConfigurationSettings.AppSettings("ConnectionString"))
>               myCommand = New SqlCommand
> ("GetListingDetail",myConnection)
>               myCommand.CommandType = CommandType.StoredProcedure
> 
>               Dim pListingID As New SqlParameter("@listingID", 
> SqlDbType.int)
>               pListingID.Value = strImageID
>               myCommand.Parameters.Add(pListingID)
>               myConnection.Open
>                 da.SelectCommand=myCommand
>               ds = New DataSet()
> 
>               da.Fill(ds, "tblListings")
>               'Dim dv as DataView = ds.Tables(0).DefaultView
>               
>                        Dim dc As DataColumn
>            
>             For Each dc In ds.Tables(0).Columns
>                 If Not dc.ColumnName = "ListingID" And Not 
> dc.ColumnName = "model" And Not dc.ColumnName = "listprice" And Not 
> dc.ColumnName = "descri" And Not dc.ColumnName = "manufacturer" And 
> Not dc.ColumnName = "comments"  And Not dc.ColumnName = "formname"  
> And Not dc.ColumnName = "username"  And Not dc.ColumnName 
> = "lblquantity" And Not dc.ColumnName = "lbllistprice" And Not 
> dc.ColumnName = "lblcomments"  And Not dc.ColumnName 
= "lbllocation"  
> And Not dc.ColumnName = "Location" Then
>                    bindcolumn(dc.ColumnName, "")
>                 End If
>            Next
> 
> End Function    
> 
>               
> Sub bindcolumn(ByVal fldname As String, ByVal formatpattern As 
String)
>         Dim objbc As BoundColumn
>         objbc = New BoundColumn()
>        ' objbc.DataField = fldname
>        ' objbc.HeaderText = fldname
>         objbc.DataFormatString = formatpattern
>                dgHyper.Columns.Add(objbc)
>         dgHyper.DataSource = ds.Tables(0)
>         dgHyper.DataBind()
> End Sub               
> 
> 
> 
> </script>    
> 
>   </head>
> <table cellspacing=0 cellpadding=0 width=500 border=0>
> <tr>
> <td valign=top>
> <asp:DataGrid 
> ID="dg_details" 
> AutoGenerateColumns=False
> Width="250"
>                       HeaderStyle-BackColor="purple"
>             HeaderStyle-ForeColor="White"
>             HeaderStyle-HorizontalAlign="Center"
>             HeaderStyle-Font-Bold="True"
>               border=0
> Runat=server>
> <Columns>
> 
> 
> <asp:TemplateColumn HeaderText="Image">
> <ItemTemplate>
>       <asp:Image Width="200" Height="200" alt="Listing Image" 
> ImageUrl='<%# FormatURL(DataBinder.Eval
> (Container.DataItem, "ListingID")) %>' Runat=server />
> 
> </ItemTemplate>                 
> 
</asp:TemplateColumn>                                                 
>                                                     
> 
> 
> </Columns>
> 
> </asp:DataGrid>
> 
> </td>
> <td>
>  <table cellspacing=0 cellpadding=0 width=250 border=0>
>  <tr><td valign=top>
> <asp:datagrid id="dgHyper" runat="server"
>  HeaderStyle-BackColor="purple"
>             HeaderStyle-ForeColor="White"
>             HeaderStyle-HorizontalAlign="Center"
>             HeaderStyle-Font-Bold="True" 
>             border="0"
> AutoGenerateColumns="False">
> <COLUMNS>
>               <asp:TemplateColumn HeaderText="Listing Info">
>       <ItemTemplate>
>         <table border="0" cellpadding=0 cellspacing=0 width=250 
> height=200>
>           <tr>
>             <td align="left"><b>Equipment Type:</b></td>
>             <td><%# DataBinder.Eval(Container.DataItem, "formname") 
%
> ></td>
>           </tr>
>            <tr>
>             <td align="left"><b>Manufacturer:</b></td>
>             <td><%# DataBinder.Eval
> (Container.DataItem, "manufacturer") %></td>
>           </tr>
>            <tr>
>             <td align="left"><b>Model:</b></td>
>             <td><%# DataBinder.Eval(Container.DataItem, "model") %
> ></td>
>           </tr>
>            <tr>
>             <td align="left"><b>Description:</b></td>
>             <td><%# DataBinder.Eval(Container.DataItem, "descri") %
> ></td>
>           </tr>
>    
>       </ItemTemplate>
>        </asp:TemplateColumn>
>        
>    
>               <asp:TemplateColumn>
>        <ItemTemplate>
>           <tr>
>             <td align="left"><b>Quantity:</b></td>
>             <td><%# DataBinder.Eval(Container.DataItem, "quantity") 
%
> ></td>
>           </tr>
>            <tr>
>             <td align="left"><b>Price:</b></td>
>             <td><%# DataBinder.Eval
(Container.DataItem, "listprice") %
> ></td>
>           </tr>
>            <tr>
>             <td align="left"><b>Comments:</b></td>
>             <td><%# DataBinder.Eval(Container.DataItem, "comments") 
%
> ></td>
>           </tr>
>            <tr>
>             <td align="left"><b>Location:</b></td>
>             <td><%# DataBinder.Eval(Container.DataItem, "Location") 
%
> ></td>
>           </tr>
>           <tr>
>             <td align="left"><b>Listed By:</b></td>
>             <td><%# DataBinder.Eval(Container.DataItem, "username") 
%
> ></td>
>           </tr>
>         </table>
>       </ItemTemplate>
>     </asp:TemplateColumn>
>     
>    
>   </Columns>  
> </asp:datagrid>
> <asp:datagrid id="dgdetails" runat="server"
>  HeaderStyle-BackColor="purple"
>             HeaderStyle-ForeColor="White"
>             HeaderStyle-HorizontalAlign="Center"
>             HeaderStyle-Font-Bold="True" 
>             border="0"
> AutoGenerateColumns="False">
> 
> </asp:datagrid>
> </td></tr>
> </table>
> 
>  </td></tr>
> </table>   
> 
> 
> 
> 
> 
> 
> 
> 
>  
> Yahoo! Groups Links



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to