Forms Data Controls :: Programmatically Display DataList (with Row Filters)?
Dec 5, 2010
I have a website developed in C# with Visual Studio 2010. I am using datalist to list the documents for monthly meetings. Each monthly meeting has 6 datalists representing each section of the monthly meeting. I am using row filters to filter the data for the respective month and section. I am using the Membership Provider model and am displaying the documents for the respective user. When a user clicks on the document link the document is marked and displayed as "read". This is all working as it should in my existing code.
However, I would like to be able to display this data programmatically. My oldest data is December 2009. I would like to dipslay this data programmatically based on todays's date and then looping back until December 2009. Today, I update the web form and the code behind on a monthly basis and I know that there is probably a better way to do this. I think this can be done but I am not certain if it can be done with row filters, because amongst other things I do not know how I can dynamically generate the datalist ids so that I can then bind the row filtered data.
Below is a sample of my code for one month of data.
I remember I read a tutorial at asp.net. The tutorial is to add a row to display the category name before a different category starts in a GridView that displays products ordered by category. But I cannot find the tutorial anymore.
I have a datalist in my site which displays html tables filled with data from a sqldatasource. I need to be able to remove one column from the table and put it back again (including the tags in my table which pull the data from the datasource e.g. <%# DataBinder.Eval(Container.DataItem,"Forecast1") %>) I need to be able to do this because I have options to change the sqldatasource query, and I need to alter the table to keep it compatible with the query. What is the best way to do this?
i want to write a page contain an datalist and several ObjectDataSource. The datalist will chose ObjectDataSource according to QuerryString passed to that page.
I have downloaded the code 39 font to display barcode in my GridView or DataList. It shows the barcode with the numeric value under it. I only want to show the barcode. how to omit numeric value from barcode?
I wanted to create a simple photo album just like facebook album feature Im able to display all albums, all pictures in thumbnail size in the album, but failed to view the image i wanted to view in normal size. This is my code in the Albumpicture.aspx which contain all images of that particular album
[Code]....
Then i use a blank page as a handler to read images from binary format in my database
[Code]....
Lastly, the albumID and photoID will pass to the photopage.aspx to display the image
[Code]....
But when i wanted to view the image in photopage.aspx, it shows a blank page. No error and nothing comes out.
I have web form and on it I have a DataList that is grabbing some Data from a Database and displaying them as a list.However when I look at the HTML Source Code produced, it's all Tables ! <td> and <tr> !!
How can I stop this ? I want my DataList to display the data like so:
I use TextEditor Obout for save datas and codes html in the DataBaseWhen call datas inside DataList texts should display aline right , display aline left
I am trying to display a starting date from an access database based on the dateId field in a datalist.
On page 1 (using a master page) the customer selects a starting date from a dropdownlist. When the customer hits the submit button, they are transferred to page 2 where the selected starting date is displayed.
I have a datalist with items for sale including an image for each item. I want to make another datalist with items that have been sold, but I want to display a part-transparent 'sold' sign across the corner of the image.
They only way I can think of is to display the item image as a background? With the sold image on top?
Any clue as to how to bring back an image from a database and display it as a background image? I haven't yet figured this out.
what it is i have a datagrid bound to a datatable.This datatable fills from a sql table. This datatable will have 2 columns which is 'part' and 'description'.What it is I want to have a couple of chk boxes next to the datagrid which will filter it by column 'part'.The issue is the datagrid will have about 1000 records so i dont want to do a for next loop searching for field part for a certain filter
I have a DataList control setup with a Repeater inside it. It's displaying Ranks just fine, but the problem is I don't know how to make it start over with each DataList.
Right now, if there are two rows in the PointsCat table, it creates two DataLists (new DataList for each ID) and populates the Repeater with the person's rank, name and points from the Points table. The CatID in the Points table is a number equal to an ID in the PointsCat table (to tell which DataList's Repeater to display the data in). This code currently just orders ALL the entries from my database table, so the first Repeater in the first DataList may end with a ranking of 4 (4th), the first item in the next DataList's Repeater starts with a rank of 5...instead of starting over with 1.
So my current page may show something like this (notice the rank didn't start over in the second category):
Points Category 1 Points Category 2 1 John Doe 400 4 Janet Doe 275 2 John Smith 390 5 Johnny Smith 270 3 Jane Smith 380
My SqlDataAdapter line is below. I need it to start over the ranking for each CatID. Is it possible to do that within this line?
I have data in mydatabase. My AnswerText in the database is test1,test2,test3 While retrieving it is displaying as test3,test1,test2. I am using the below code to display the data.
Dictionary<string, string> dicKeyValues = new Dictionary<string, string>(); for (int i = 0; i < cnstsData.Answer.Count; i++) { dicKeyValues.Add(AnswerText, AnswerImage); } DataList.DataSource = dicKeyValues; DataList.DataBind();
I want to display the AnswetText as test1,test2,test3. Basically i want the same order which i added to the database while retrieving also.
Is it possible to use dynamic query filters with a gridview using a stored procedure as a data source? What I'm thinking of is a search page where there are multiple controls to enter in a search string and a radio button for the AND/OR query filters between the various controls. If not, what would be the best way to allow a user to select an AND / OR with a group of different query controls?
Here is the page I have created thus far using a view and no AND/OR option. I but I can't get it to work with my SP, also listed below:
I am using a datalist to display data from a database.Except for 1 column all the other column values are getting repeated so I am hiding all the other column values when the datalist repeats itself.However, the unique column value is not getting rendered properly because there are many line breaks in between.I am not using any web control to display the static text and I am not sure if that would help.I just want to improve the final display so that the datalist looks consistent.I am attaching my code.
I have a datalist and want the results paged I have written a pager.ascx page and have an aspx and aspx.cs page to display the results. I have a stored procedure to pull the data out of the database and a class to talk between the stored procedure and presentation controls I have the pager being displayed when the results get over the limit I have set to 10 in the web.config file but when i click on the next link to display the next page of results it doesn't do anything. my aspx page is
<uc1:Pager ID="topPager" runat="server" Visible="False" /> <asp:DataList ID="newsList" runat="server" CssClass="List" align="center"> <ItemStyle CssClass="ItemList" /> <ItemTemplate> <h2><%# Eval("Title") %></h2> <p>Posted <%# Eval("Date") %></p> <p><%# Eval("News").ToString().Replace(" ", "<br />") %></p> </ItemTemplate> </asp:DataList> <uc1:Pager ID="bottomPager" runat="server" Visible="False" /> my aspx.cs page is protected void Page_Load(object sender, EventArgs e) { // Retreive page from the query string string page = Request.QueryString["Page"]; if (page == null) page = "1"; // How many pages of posts int howManyPages = 1; // pager links format string firstPageUrl = ""; string pagerFormat = ""; //DataAccess.GetNews returns a DataTable object containing news data which is read into datalist newsList.DataSource = DataAccess.GetNews(page, out howManyPages); // Bind the data to the data source newsList.DataBind(); // have the current page as interger int currentPage = Int32.Parse(page); // Display pager controls topPager.Show(int.Parse(page), howManyPages, firstPageUrl, pagerFormat, false); bottomPager.Show(int.Parse(page), howManyPages, firstPageUrl, pagerFormat, true); } my pager.ascx page is <p> Page <asp:Label ID="currentPagelabel" runat="server" /> of <asp:Label ID="howManyPageLabel" runat="server" /> | <asp:HyperLink ID="previousLink" runat="server">Previous</asp:HyperLink> <asp:Repeater ID="pagesRepeater" runat="server"> <ItemTemplate> <asp:HyperLink ID="hyperlink" runat="server" Text='<%# Eval("Page") %>' NavigateUrl='<%# Eval("Url") %>' /> </ItemTemplate> </asp:Repeater> <asp:HyperLink ID="nextLink" runat="server">Next</asp:HyperLink> </p> my pager.aspx.cs page is using System; // Simple struct that represents a (page number, url) association public struct PageUrl { private string page; private string url; // Page property definition public string Page { get { return page; } } // Url property definition public string Url { get { return url; } } // Constructor public PageUrl(string page, string url) { this.page = page; this.url = url; } } // The pager control public partial class UserControls_Pager : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { } // Show the pager public void Show(int currentPage, int howManyPages, string firstPageUrl, string pageUrlFormat, bool showPages) { // Display paging controls if (howManyPages > 1) { // make the pager visable this.Visible = true; // Display the current page currentPagelabel.Text = currentPage.ToString(); howManyPageLabel.Text = howManyPages.ToString(); // Create the Previous link if (currentPage == 1) { previousLink.Enabled = false; } else { previousLink.NavigateUrl = (currentPage == 2) ? firstPageUrl : String.Format(pageUrlFormat, currentPage - 1); } // Create the Next link if (currentPage == howManyPages) { nextLink.Enabled = false; } else { nextLink.NavigateUrl = String.Format(pageUrlFormat, currentPage + 1); } // Create the page links if (showPages) { // The list of pages and their URLs as an array PageUrl[] pages = new PageUrl[howManyPages]; // Generate (page, url) elements pages[0] = new PageUrl("1", firstPageUrl); for (int i = 2; i <= howManyPages; i++) { pages[i - 1] = new PageUrl(i.ToString(), String.Format(pageUrlFormat, i)); } // Do not generate a link for current page pages[currentPage - 1] = new PageUrl((currentPage).ToString(), ""); // Feed the pages to the repeater pagesRepeater.DataSource = pages; pagesRepeater.DataBind(); } } } } my class file is // Retreive the list of news posts public static DataTable GetNews(string pageNumber, out int howManyPages) { // Get a configured DbCommand object DbCommand comm = GenericDataAccess.CreateCommand(); // Set the stored procedure name comm.CommandText = "GetNews"; // create a new parameter for page number DbParameter param = comm.CreateParameter(); param.ParameterName = "@PageNumber"; param.Value = pageNumber; param.DbType = DbType.Int32; comm.Parameters.Add(param); // create a new parameter for products per page param = comm.CreateParameter(); param.ParameterName = "@PostsPerPage"; param.Value = PlatiumMindProductionsConfiguration.PostsPerPage; param.DbType = DbType.Int32; comm.Parameters.Add(param); param = comm.CreateParameter(); param.ParameterName = "@HowManyPosts"; param.Direction = ParameterDirection.Output; param.DbType = DbType.Int32; comm.Parameters.Add(param); // Execute the stored procedure and saven the results in a DataTable DataTable table = GenericDataAccess.ExecuteSelectCommand(comm); // Calculate how many pages of posts and set the out parameter int howManyPosts = Int32.Parse(comm.Parameters["@HowManyPosts"].Value.ToString()); howManyPages = (int)Math.Ceiling((double)howManyPosts / (double)PlatiumMindProductionsConfiguration.PostsPerPage); // return the page of posts return table; } my stored procedure is ALTER PROCEDURE [dbo].[GetNews] (@PageNumber INT, @PostsPerPage INT, @HowManyPosts INT OUTPUT) AS -- Declare a new table DECLARE @News TABLE (RowNumber INT, NewsID INT, Title NVARCHAR(50), Date DATETIME, News NVARCHAR(MAX)) -- Populate the table with the complete list INSERT INTO @News SELECT ROW_NUMBER() OVER (ORDER BY NewsID desc), NewsID, Title, Date, News FROM News -- return the total number of posts SELECT @HowManyPosts = COUNT(NewsID) FROM News -- extract the request page of posts SELECT NewsID, Title, DATE, News FROM @News WHERE RowNumber > (@PageNumber - 1) * @PostsPerPage AND RowNumber <= @PageNumber * @PostsPerPage
I have a datalist inside 1 datalist.In the first datalist i am binding the "advertisement posted" date field from sql server. In the second datalist i am binding the ads posted on that date using an object datasource. my pro is, i need to show a total of 100 ads in one page. This should not depend on the date. Total 100 postings in the page. For example
Todays date (02/25/2010) 50 postings yesterdays date (02/24/2010)
if 75 postings are there,
50 postings
it should display only 50 postings under yesterday's date remaining 25 postings should display in next page(paging) with the format like this
yesterdays date (02/24/2010) remaining 25 postings (02/23/2010) 75 postings
Am using datalist to create a kinsd of message board, in the back end am having two tables one for the parent comment , and other for the child comments
The data source is extracted by LINQ to SQL with the load option , so I get everthing when I debug on the code behind , and I can see all the fields each parent comment and the child comments.
the problem is with binding the data on the disply for example all the parent table fildes can be rendred without any problems:
<%# DataBinder.Eval(Container.DataItem, "comment1Parent") %>; "showing me the orginal post"
Problem here:
<%# DataBinder.Eval(Container.DataItem, "Childcomment") %> is not rendred and I got this error msg:
DataBinding: 'DataAccessLayer.Comment' does not contain a property with the name 'childComment'. In the debug I navigate to the childComment and this is its HTML visualisar:
new System.Linq.SystemCore_EnumerableDebugView<DataAccessLayer.Comment>(((ASP.usercontrols_comments_ascx)this).Comments)).Items[0]._comments_Replies.entities.items[0].childComment
wondering if someone can possibly help me out with a gridview. I have data coming into a grid and I know how to filter the data using one dropdown, I'm trying to get a little more advanced now. I'd like to filter using three dropdowns.
This is what I have so far: I don't know how to hook the downlists to the query?