Which Data Presentation Control?

hi

in my project i have a  directors page which includes their picture information and filmography. I want to show filmography in different data presentation control than the other data. And i want to show it with this stored procedure:

select Film from Films inner join Film_Director on Films.id=Film_Director .fid where yid=@id

but i have InCollection field in Films table and in my data presentation control i want to change the color of Film's Text by InCollection. If InCollection=true for that movie that row's text should be green if false should be red for example.

 So which control is best for this situation? And which event should i use for changing color of text?

0
elephantman
8/28/2008 12:52:00 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

6 Replies
907 Views

Similar Articles

[PageSpeed] 22

Datalist


Jai Ganesh. J , GSD ,India

Please Mark As Answer If my reply helped you.
0
Ganesh
8/28/2008 1:29:19 PM

ok and here is my datalist :

 

 <asp:DataList ID="DataList1" runat="server">
                <ItemTemplate>
                <%# Eval("FilmAdi")%>
                </ItemTemplate>
 </asp:DataList>

 and my databinding code in cs:

string strConnString = ConfigurationManager.ConnectionStrings["DVDArsivConnectionString2"].ConnectionString;
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(strConnString);
        SqlCommand sorgu = new SqlCommand();
        sorgu.Connection = con;
        sorgu.CommandType = CommandType.StoredProcedure;
        sorgu.CommandText = "sp_Filmografi";
        con.Open();

        SqlDataAdapter sorgu1DA = new SqlDataAdapter(sorgu);
        sorgu1DA.SelectCommand.Parameters.AddWithValue("id", Convert.ToInt32(Request.QueryString["id"]));
        DataTable DTable = new DataTable();
        sorgu1DA.Fill(DTable);
        DataList1.DataSource = DTable;
        DataList1.DataBind();
        con.Close();

    }

 

now in which event can i change <%# Eval("FilmAdi")%> 's text color? and what object should i use to do that?

0
elephantman
8/28/2008 2:21:48 PM

elephantman:

 now in which event can i change <%# Eval("FilmAdi")%> 's text color? and what object should i use to do that?

i tried like this. "aspx" page

<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
InTheaters: <asp:Label ID="InTheatersLabel" runat="server" Text='<%# Eval("InTheaters") %>' ></asp:Label><br />
Title: <asp:Label ID="TitleLabel" runat="server" Text='<%# FormatTitle(Eval("Title"), Eval("InTheaters")) %>'></asp:Label><br />
<br /> </ItemTemplate>
</asp:DataList></div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [InTheaters], [Title] FROM [Movies]"></asp:SqlDataSource>

codebehind

public string FormatTitle(Object title, object intheatres )
{
bool boolIntheatres = (bool)intheatres;
if (boolIntheatres == true)
{
return "<span style=color:green>" + title.ToString().ToUpper() + "</span>";
}
else
{
return "<span style=color:red>" + title.ToString().ToUpper() + "</span>";
}
}

"intheatres" is boolean field. "title" is text field.

if the boolean is true then i change the color of the title to "green" or to "red"


Jai Ganesh. J , GSD ,India

Please Mark As Answer If my reply helped you.
0
Ganesh
8/28/2008 3:40:15 PM

now this is my data list:

 

  <asp:DataList ID="DataList1" runat="server">
                <ItemTemplate>
                
                <asp:Label ID="TitleLabel" runat="server" 
                Text='<%# FormatTitle(Eval("FilmAdi"),Eval("InCollection"))%>'></asp:Label>
                              
                </ItemTemplate>
                </asp:DataList>

 and this is my cs code:

 string strConnString = ConfigurationManager.ConnectionStrings["DVDArsivConnectionString2"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)

{

SqlConnection con = new SqlConnection(strConnString);SqlCommand sorgu = new SqlCommand();

sorgu.Connection = con;

sorgu.CommandType = CommandType.StoredProcedure;

sorgu.CommandText = "sp_Filmografi";

con.Open();

SqlDataAdapter sorgu1DA = new SqlDataAdapter(sorgu);

sorgu1DA.SelectCommand.Parameters.AddWithValue("id", Convert.ToInt32(Request.QueryString["id"]));

DataTable DTable = new DataTable();

sorgu1DA.Fill(DTable);

DataList1.DataSource = DTable;

DataList1.DataBind();

con.Close();

}

public string FormatTitle(Object title, Object incollection)

{

bool boolincollection = (bool)incollection;

if (boolincollection == true)

{

return "<span style=color:green>" + title.ToString() + "</span>";

}

else

{

return "<span style=color:red>" + title.ToString() + "</span>";

}

}

i got error with this code the error is : Specified cast is not valid. (shown this line : bool boolincollection = (bool)incollection; )

and i have another question: if this error is gone i think with this code users can see InCollection field is true or false but i dont want to show it, i want to show it only colors if it is true only Fim name is shown with green color if it is false only Film name is shown with red color. so the above code (if it works) satisfies me or not?

0
elephantman
8/29/2008 12:12:27 PM

elephantman:

FormatTitle(Object title, Object incollection)

{

bool boolincollection = (bool)incollection;

if (boolincollection == true)

{

return "<span style=color:green>" + title.ToString() + "</span>";

}

else

{

return "<span style=color:red>" + title.ToString() + "</span>";

}

}

is this variable a "incollection" is a "bit" datatype in sqldatabase ? if is then casting would not give error.

2. if u dont want "true" "false" value then dont display the item in the "itemtemplate" field

 


Jai Ganesh. J , GSD ,India

Please Mark As Answer If my reply helped you.
0
Ganesh
8/29/2008 2:44:13 PM

oh SORRY it was my mistake :( yes it was a bit field but because of added lately i forgot to fill the InCollection value of movies. Now it work really nice THANKS!

0
elephantman
8/29/2008 3:05:26 PM
Reply:

Web resources about - Which Data Presentation Control? - asp.net.presentation-controls

Presentation High School - Wikipedia, the free encyclopedia
... 121°54′W  /  37.283°N 121.900°W  / 37.283; -121.900 Coordinates : 37°17′N 121°54′W  /  37.283°N 121.900°W  / 37.283; -121.900 Presentation ...

authorSTREAM App Brings PowerPoint Presentations To Facebook
PowerPoint presentations aren’t just for conference rooms anymore, as Facebook application authorSTREAM allows users to upload presentations ...

Presentation Shows Facebook Ad Product Roadmap: Page Metrics, Real Time Ads, No Banners
A document accidentally revealed by a Facebook advertising partner in Poland provides new details on the company’s ad product roadmap. The presentation ...

Lessonator: Create music slideshow presentations
Lessonator is a tool for creating beautiful music slideshow presentations on your Mac. It works like a mashup between Apple’s Keynote and Garageband, ...

Scripting News: Create a presentation in Fargo.
... move my whole act over there, but in the meantime, here's a pointer to my latest piece. http://dave.smallpict.com/2013/06/28/howToCreateAPresentationInFargo ...

12 Minutes To Create a Mind-Changing Presentation
Reading this blog article will take you only 12 minutes — 12 minutes to find out how to draft great presentations and to become a more effective ...

App Store - SlideShark: View & Share Presentations
Get SlideShark: View & Share Presentations on the App Store. See screenshots and ratings, and read customer reviews.

Football Manager 2016 review: Presentation makes perfect
At one point it was all going smoothly. Inspired by Jurgen Klopp, my Liverpool team was playing a high-pressure, high-tempo game that even the ...

PowerPoint Presentation of the Darned
... PowerPoint deck from Jeb’s recent “Imma Tell My Mom, Dad and Big Brother You Were MEAN to Me” conference. There are 112 slides in the presentation. ...

Valeant Hits a Two-Year Low After Ackman's Presentation
Valeant Pharmaceuticals International Inc. tumbled to a two-year low, closing out its worst month ever, after billionaire shareholder William ...

Resources last updated: 12/6/2015 6:02:07 PM