Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
ASP.NET
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="FrmSearchResult.aspx.cs" Inherits="WebApplication1.FrmSearchResult" %>

<%@ Register Assembly="DevExpress.Web.v13.2, Version=13.2.9.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>

<%@ Register Assembly="DevExpress.Web.v13.2, Version=13.2.9.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxNewsControl" TagPrefix="dx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <div style="float: left; width: 650px; margin-removed 16px">
        <dx:ASPxNewsControl Width="100%" DataSourceID="LinqDataSource1" ID="newsControl" EnableViewState="False"
             runat="server" NavigateUrlFormatString="~/WebForm1.aspx?id={0};" TextField="prDescription" DateField="prTimeUploaded" HeaderTextField="university"
             DataMember="prDescription" ImageUrlField="prId" NameField="prName"  önItemDataBound="newsControl_ItemDataBound" >
            <ItemSettings ShowImageAsLink="True" MaxLength="120" TailText="Details">
            </ItemSettings>
            <PagerSettings CurrentPageNumberFormat="{0}" NumericButtonCount="5">
                <NextPageButton Visible="True">
                </NextPageButton>
                <PrevPageButton Visible="True">
                </PrevPageButton>
            </PagerSettings>
           
           
            <ItemImage Height="200px" Width="200px">
            </ItemImage>
           
           
        </dx:ASPxNewsControl>
    </div>    
    <asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="WebApplication1.App_Code.imgGlryDsplyDataContextDataContext" EntityTypeName="" TableName="productsTbls"></asp:LinqDataSource>
</asp:Content>

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebApplication1.App_Code;

namespace WebApplication1
{
    public partial class FrmSearchResult : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["nameA"] != null)
            {
             
                string searchTarget = Session["nameA"].ToString();
                imgGlryDsplyDataContextDataContext db = new imgGlryDsplyDataContextDataContext();
                if (!Page.IsPostBack)
                {
                    //Bind the AspXNewsControl
                    newsControl.DataSourceID = "";
                    imgGlryDsplyDataContextDataContext context = new imgGlryDsplyDataContextDataContext();
                    var query = from pro in context.productsTbls
                                join usr in context.userTbls on pro.prUploadedBy equals usr.userId
                                join univ in context.universityTbls on usr.universityId equals univ.universityId
                                orderby pro.prTimeUploaded descending
                                where pro.prName.Contains(searchTarget.Trim())
                                select new
                                {
                                    univ.university,
                                    pro.prName,
                                    pro.prId,
                                    pro.prTimeUploaded,
                                    pro.prDescription,
                                    pro.prPic1
                                };


                    newsControl.DataSource = query.ToList();
                    newsControl.DataBind();
                }

     
            }

        }

        protected void Button1_Click(object sender, EventArgs e)
        {

        }

        protected void newsControl_ItemDataBound(object source, DevExpress.Web.ASPxNewsControl.NewsItemEventArgs e)
        {
            e.Item.Image.Url = "getImage.ashx?prId=" + e.Item.Image.Url;

        }
    }
}
Posted
Updated 31-Jul-14 7:20am
v3
Comments
ZurdoDev 30-Jul-14 16:16pm    
Please debug it and let us know where you are stuck.
ameshaspanta 30-Jul-14 16:31pm    
I debugged the code, FrmSearchResult does not have anything!
My goal is displaying the control with the data which are bond to it.
Thank you so much for your consideration
ZurdoDev 30-Jul-14 16:35pm    
So, why does it not return any data?
ameshaspanta 30-Jul-14 16:39pm    
Actually query result is correct and DataBind() executes correctly, but nothing is not displayed in FrmSearchResult!
ZurdoDev 30-Jul-14 16:40pm    
You're sure there is data? Then you'll need to show the data bindings for newsControl, what that is.

1 solution

I found the solution!
here is the code:
ASP.NET
<![CDATA[<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="FrmSearchResult.aspx.cs" Inherits="WebApplication1.FrmSearchResult" %>]]>

<![CDATA[<%@ Register Assembly="DevExpress.Web.v13.2, Version=13.2.9.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>]]>

<![CDATA[<%@ Register Assembly="DevExpress.Web.v13.2, Version=13.2.9.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxNewsControl" TagPrefix="dx" %>]]>
<asp:content id="Content1" contentplaceholderid="head" runat="server" xmlns:asp="#unknown">
</asp:content>
<asp:content id="Content2" contentplaceholderid="ContentPlaceHolder1" runat="server" xmlns:asp="#unknown">

    <div style="float: left; width: 650px; margin-right: 16px">
        <dx:aspxnewscontrol width="100%" datasourceid="LinqDataSource1" id="newsControl" enableviewstate="False" xmlns:dx="#unknown">
            runat="server" NavigateUrlFormatString="~/WebForm1.aspx?id={0};" TextField="prDescription" DateField="prTimeUploaded" HeaderTextField="university"
             DataMember="prDescription" ImageUrlField="prId" NameField="prName" OnItemDataBound="newsControl_ItemDataBound" >
            <itemsettings showimageaslink="True" maxlength="120" tailtext="Details">
            </itemsettings>
            <pagersettings currentpagenumberformat="{0}" numericbuttoncount="5">
                <nextpagebutton visible="True">
                </nextpagebutton>
                <prevpagebutton visible="True">
                </prevpagebutton>
            </pagersettings>
           
           
            <itemimage height="200px" width="200px">
            </itemimage>
           
           
        </dx:aspxnewscontrol>
    </div>    
    <asp:linqdatasource id="LinqDataSource1" runat="server" contexttypename="WebApplication1.App_Code.imgGlryDsplyDataContextDataContext" entitytypename="" tablename="productsTbls"></asp:linqdatasource>
</asp:content>


ASPxNewsControl has a event handle ItemDataBound:

C#
protected void newsControl_ItemDataBound(object source, DevExpress.Web.ASPxNewsControl.NewsItemEventArgs e)
       {
           e.Item.Image.Url = "getImage.ashx?prId=" + e.Item.Image.Url;

       }
 
Share this answer
 
Comments
Member 12268400 1-Oct-16 17:55pm    
Can you post the "getImage.ashx" file?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900