Category Archives: ObjectDataSource

ObjectDataSource

cascadingdropdrow & detailaview & problme

i understand a title english , please help me to solving this problme

just update button in detailsview not work , insert & edit & edit works well …

why update linkbutton in detailsview in my page with Cascadingdropdrown  not work !!!

this is my code

please help me , where i used without  cascadingdropdrown , update detailsview  work very well …

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CarsRentalList.aspx.cs"
    EnableEventValidation="false" Inherits="App.AppUsers.CarsRentalList" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../App_Themes/Css/General.css" rel="stylesheet" type="text/css" />
    <link href="../css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
        <Services>
            <asp:ServiceReference Path="~/CityService.asmx" />
        </Services>
    </asp:ScriptManager>
    <asp:Panel ID="Panel1" runat="server" DefaultButton="LinkButton1">
        <div class="row" style="direction: rtl; width: 800px; position: relative;">
            <div class="divInline" style="width: 350px;">
                <div class="row">
                    <asp:Label ID="lblProvinceS" CssClass="lbl" runat="server" Text="Province"></asp:Label>
                    <asp:DropDownList ID="ddlstProvinceS" runat="server">
                    </asp:DropDownList>
                    <asp:CascadingDropDown ID="ddlstProvinceS_CascadingDropDown" runat="server" PromptText="select province"
                        ServicePath="~/CityService.asmx" ServiceMethod="GetProvince" Category="Province"
                        TargetControlID="ddlstProvinceS">
                    </asp:CascadingDropDown>
                </div>
                <div class="row">
                    <asp:Label ID="lblCityS" CssClass="lbl" runat="server" Text="City"></asp:Label>
                    <asp:DropDownList ID="ddlstCityS" runat="server" />
                    <asp:CascadingDropDown ID="ddlstCityCddS" runat="server" TargetControlID="ddlstCityS"
                        ParentControlID="ddlstProvinceS" ServicePath="~/CityService.asmx" ServiceMethod="GetCities"
                        Category="Cities" LoadingText="please wait ..." PromptText="select city">
                    </asp:CascadingDropDown>
                    <asp:HiddenField ID="hdn" runat="server" />
                </div>
            </div>
        </div>
    </asp:Panel>

    <div class="row">
        <%-- <asp:UpdatePanel ID="UpView" runat="server" UpdateMode="Conditional">
                <ContentTemplate>--%>
        <div class="row" style="direction: rtl; width: 800px; position: relative;">
            <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="CompanyId,IdCitySource,IdCityDestination,TypeOfTrailer"
                DataSourceID="ObjectDataSource1" Height="50px" Width="250px" OnItemUpdating="DetailsView1_ItemUpdating1">
                <Fields>
                    <asp:BoundField DataField="CompanyId" HeaderText="CompanyId" ReadOnly="True" SortExpression="CompanyId" />
                    <asp:BoundField DataField="IdCitySource" HeaderText="IdCitySource" ReadOnly="True"
                        SortExpression="IdCitySource" />
                    <asp:BoundField DataField="IdCityDestination" HeaderText="IdCityDestination" ReadOnly="True"
                        SortExpression="IdCityDestination" />
                    <asp:BoundField DataField="TypeOfTrailer" HeaderText="TypeOfTrailer" ReadOnly="True"
                        SortExpression="TypeOfTrailer" />
                    <asp:BoundField DataField="CarRentalRates" HeaderText="CarRentalRates" SortExpression="CarRentalRates" />
                    <asp:BoundField DataField="CtiySourceName" HeaderText="CtiySourceName" SortExpression="CtiySourceName" />
                    <asp:BoundField DataField="CityDestinationName" HeaderText="CityDestinationName"
                        SortExpression="CityDestinationName" />
                    <asp:CommandField ShowEditButton="True" />
                </Fields>
            </asp:DetailsView>
        </div>
        <%-- </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="LinkButton1" EventName="Click" />
                </Triggers>
            </asp:UpdatePanel>--%>
    </div>

………

please help me , where i using without  cascadingdropdrown , update detailsview  work very well …

Bind FormView Dropdownlist in Accordion

Hi 

I have an DropDownList in a FormView, and the FormView is in an Accordion, which I am trying to bind.
The page is also using a master page.
My code doesn’t return an error but it also doesn’t Bind the DropDownList…it is as if the Accordion’s "ItemDataBound" is never called?

<asp:Accordion ID="accCaptureMethod"
        runat="Server"
        HeaderCssClass="accordionMenuHeader"
        HeaderSelectedCssClass="accordionMenuHeaderSelected"
        ContentCssClass="accordionContent"
        AutoSize="None"
        FadeTransitions="true"
        TransitionDuration="250"
        FramesPerSecond="40"
        RequireOpenedPane="false"
        SuppressHeaderPostbacks="true"
        OnItemDataBound="accCaptureMethod_ItemDataBound">
        <Panes>
            <asp:AccordionPane ID="accpTransaction" runat="server" >
                <Header>3) Capture transaction</Header>
                <Content>
                    <asp:FormView ID="fvTrans" runat="server" DataKeyNames="Id"           DataSourceID="ObjectDataSource1" DefaultMode="Insert">
                        <InsertItemTemplate>
                            <table>
                                <tr>
                                    <td>Scheme:</td>
                                </tr>
                                <tr>
                                    <td>
                                        <asp:DropDownList ID="ddlScheme_trans" runat="server" ></asp:DropDownList>
                                    <td>
                                </tr>
                            </table>
                            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Insert" />
                            &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                        </InsertItemTemplate>
                    </asp:FormView>
                </Content>
            </asp:AccordionPane>
        </Panes>
    </asp:Accordion>



    protected void accCaptureMethod_ItemDataBound(object sender, AjaxControlToolkit.AccordionItemEventArgs e)
    {
        if (e.AccordionItem.ItemType == AjaxControlToolkit.AccordionItemType.Content)
        {
            string strRefKey = Profile.RefKey.ToString();
            MyTableAdapters.SchemesTableAdapter schemeAdapter = new MyTableAdapters.SchemesTableAdapter();
            MyDataSet.SchemesDataTable schemes;
            schemes = schemeAdapter.GetMySchemes(strRefKey);

            DropDownList ddlScheme_trans = (DropDownList)e.AccordionItem.FindControl("fvTrans").FindControl("ddlScheme");
            ddlScheme_trans.DataSource = schemes;
            ddlScheme_trans.DataTextField = "SchemeName";
            ddlScheme_trans.DataValueField = "SchemeId";
            ddlScheme_trans.DataBind();
            ListItem listItem = new ListItem("--- Select scheme ---", "0", true);
            listItem.Selected = true;
            ddlScheme_trans.Items.Add(listItem);
        }
    }

I did come accross those post.

The 1st one seems to be the same issue. I did implement what was suggested in my code above, but it doesn’t solve my issue.

Anyone else?

[RESOLVED]cascading Problme & DetailsView

hi …

sorry i have a little english … i’m using cascadingDropDown extender with dropdrowlist and  binding detailsview to 4 parameter in my page …. for objectdatasource insert , delete , select  works well but update Not work …!!!

without cascadingdropdrown , update of objectdatasorce work well ….  WHY …

i set updateMethod well …

please help me , i’m tired to search for it …

why Update button in detailsview  not work ????????

tnx

[RESOLVED]Dropdownlist Selected index change inside a datalist

<asp:DataList ID="DataList1" runat="server" RepeatColumns="4" RepeatDirection="Horizontal"
                        ForeColor="#333333" BackColor="Gray" Width="100%" BorderColor="Gray" BorderWidth="5px"
                         OnItemCommand="DL_Itemcommand" OnItemDataBound="DL_ItemDataBound" s>
                        <AlternatingItemStyle CssClass="styleP2" />
                        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                        <ItemStyle CssClass="styleP1" />
                        <ItemTemplate>
                            <asp:Panel ID="PanelP" runat="server" BorderColor="Transparent" BorderWidth="3px"
                                Height="150px" Width="300px" ScrollBars="None">
                              <table>
                        <tr>
                        <td>
                        Items:
                               <asp:Label ID="lblitem" runat="server" Visible="false" Text='<%#Eval("ITEM") %>'> </asp:Label>
                                <asp:DropDownList ID="DDLItems" runat="server" BackColor="Gray" AutoPostBack="true"
                                 OnSelectedIndexChanged="DDLItems_SelectedIndexChanged">
                                        <asp:ListItem Text="item1" Value="1" />
                                        <asp:ListItem Text="item2" Value="2"  />
                                        <asp:ListItem Text="item3" Value="3"  />
                                        <asp:ListItem Text="item4" Value="4"  />
                                        <asp:ListItem Text="item5" Value="5"  />
                                 </asp:DropDownList>
                                 
                        </td></tr>
                        <tr><td style="vertical-align:middle;height:25px">
                                <%--code for other items in datalist like linkbuttons,labels etc--%>
                                </td></tr></table>
                                <asp:Panel ID="PanelDetails" runat="server" BorderColor="Transparent"
                                    Height="125px" Width="273px" ScrollBars="Auto">
                                    <%--a gridview for the details--%>  </asp:Panel>
                            </asp:Panel>
                        </ItemTemplate>
                        <SelectedItemStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                    </asp:DataList>
                    <asp:ObjectDataSource ID="DSDataList1" runat="server" TypeName="Common.DAO"
                        SelectMethod="GetSortedList" OnSelecting="DSDataList1_Selecting">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="ddlList" Name="ID" DefaultValue="0" Type="String" />
                            <asp:Parameter Name="sortExpression" Type="String" />
                        </SelectParameters>
                    </asp:ObjectDataSource>

For the above datalist Itemtemplate has a dropdown with 5 items.,the DropdownItems selected index changed event(DDLItems_SelectedIndexChanged) is not Fired

Used the ItemDataBound event .But every time when i select an item the page loads and the selected value of dropdownitems become the first one in the list.How to get the selected value correctly.(selection is done by the client).

Can you please share your cs code? it seems that you are rebinding the datalist outside of if(!IsPostBack) which causes to select the initial value of dropdownlist. please look into your code.

Are you binding the datalist in page_load maybe? If so make sure you do that inside of an if (!IsPostBack) block. 

[RESOLVED]tutorial showing a nested GridView, or maybe DetailsView within a GridView, or similar??

Hello-

My app’s in VS 2010 on .NET 4 using an EF model layer with SQL CE.  I need to create a page that (more or less) looks like a grid within a grid: Each row in the containing grid followed (immediately) by a few rows in the contained grid, then back to a containing
grid row, detail rows, repeat).  I’m not that familiar with the components, just guessing a GridView and a DetailsView would be a good fit.  But all the tutorials I find show a GridView with no details inside it, followed by a single DetailsView down below/outside
of the first grid (only showing the details of a single, selected row at a time).

I don’t need to select/edit/delete anything in the main grid, but I do need to select/edit/delete in the detailed grid.

Definitely open to alternatives, but hoping for a tutorial/demo to walk me through.

Thanks for any help!

This is possible. Matt Berseth has a good article that shows off putting a GridView in a ListView control:

The only downside is that it uses a linqdatasource to get the information where I prefer to use ObjectDataSource. I think the important part of the tutorial is that you can see the nested listview uses a databinding expression which binds an element from
the parent in as the datasource for the nested:

DataSource='<%# Eval("Items") %>'

http://mattberseth.com/WindowsLiveWriter/6bfd1a9e4b9e_10957/image_cb0746f3-cb82-4bf8-a800-2e4ef796616a.png

Hope this gives you the right idea…

prk_in

Gridview inside Gridview refer

http://www.aspdotnet-suresh.com/2012/05/gridview-with-in-gridview-or-nested.html

I had a look at this code and I just wanted to point out that this does a database select for every sub gridview which would get pretty intensive (slow) if there are a lot of rows.

Hi ottenm,

Based on your description, I think we can use gridview inside gridview to solve it, so please try to refer to the following sample code, which provided by @park_in.

In the aspx file:

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Gridview within Gridivew - Nested gridview example in asp.net </title>
<script language="javascript" type="text/javascript">
function divexpandcollapse(divname) {
var div = document.getElementById(divname);
var img = document.getElementById('img' + divname);
if (div.style.display == "none") {
div.style.display = "inline";
img.src = "minus.gif";
} else {
div.style.display = "none";
img.src = "plus.gif";
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="gvParentGrid" runat="server" DataKeyNames="CountryId" Width="300"
AutoGenerateColumns="false" OnRowDataBound="gvUserInfo_RowDataBound" GridLines="None" BorderStyle="Solid" BorderWidth="1px"  BorderColor="#df5015">
<HeaderStyle BackColor="#df5015" Font-Bold="true" ForeColor="White" />
<RowStyle BackColor="#E1E1E1" />
<AlternatingRowStyle BackColor="White" />
<HeaderStyle BackColor="#df5015" Font-Bold="true" ForeColor="White" />
<Columns>
<asp:TemplateField ItemStyle-Width="20px">
<ItemTemplate>
<a href="JavaScript:divexpandcollapse('div<%# Eval("CountryID") %>');">
<img id="imgdiv<%# Eval("CountryID") %>" width="9px" border="0" src="plus.gif" />
</a>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="CountryId" HeaderText="CountryId" HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="CountryName" HeaderText="CountryName" HeaderStyle-HorizontalAlign="Left" />
<asp:TemplateField>
<ItemTemplate>
<tr>
<td colspan="100%">
<div id="div<%# Eval("CountryID") %>" style="display: none; position: relative; left: 15px; overflow: auto">
<asp:GridView ID="gvChildGrid" runat="server" AutoGenerateColumns="false" BorderStyle="Double"  BorderColor="#df5015" GridLines="None" Width="250px">
<HeaderStyle BackColor="#df5015" Font-Bold="true" ForeColor="White" />
<RowStyle BackColor="#E1E1E1" />
<AlternatingRowStyle BackColor="White" />
<HeaderStyle BackColor="#df5015" Font-Bold="true" ForeColor="White" />
<Columns>
<asp:BoundField DataField="StateID" HeaderText="StateID" HeaderStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="StateName" HeaderText="StateName" HeaderStyle-HorizontalAlign="Left" />
</Columns>
</asp:GridView>
</div>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html

In the aspx.cs file:

SqlConnection con = new SqlConnection("Data Source=SureshDasari;Integrated Security=true;Initial Catalog=MySampleDB");

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGridview();
}
}
// This method is used to bind gridview from database
protected void BindGridview()
{
con.Open();
SqlCommand cmd = new SqlCommand("select TOP 4 CountryId,CountryName from Country", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
gvParentGrid.DataSource = ds;
gvParentGrid.DataBind();

}
protected void gvUserInfo_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
con.Open();
GridView gv = (GridView)e.Row.FindControl("gvChildGrid");
int CountryId = Convert.ToInt32(e.Row.Cells[1].Text);
SqlCommand cmd = new SqlCommand("select * from State where CountryID=" + CountryId, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
gv.DataSource = ds;
gv.DataBind();
}
}

Hope it can help you, if you have question please let me know.

Best Regards,
Terry Guo

>

hi,

use can use customize griedview Or details view also chiled control any

ex:-

<asp:GridView
ID="GridView1"
runat="server">

<Columns>

<asp:BoundField
HeaderText=""
DataField=""
/>

<asp:TemplateField>

<ItemTemplate>

<asp:DetailsView
ID="DetailsView1"
runat="server"
Height="50px"
Width="125px">

<Fields>
<asp:BoundField
HeaderText=""
DataField=""
/>

<asp:BoundField
HeaderText=""
DataField=""
/>

</Fields>

</asp:DetailsView>
</ItemTemplate>
</asp:TemplateField>

</Columns>
</asp:GridView>

protected
void GridView1_RowDataBound(object
sender,
GridViewRowEventArgs e)
{
DetailsView
dt;

if
(e.Row.RowType==
DataControlRowType.DataRow)
{

dt =new
DetailsView();

dt
= (DetailsView)GridView1.FindControl("DetailsView1");

dt.DataSource
="Any
Data set"
;

dt.DataBind();
}

}

 

Thanks a ton to all!  Used something from every post, ended up with a details view inside a gridview.  Couldn’t be happier!

ObjectDataSource can't see business objects in app_code

 

Ok, here’s a strange one.

If I do the following:

1. Create a simple web site
2. Create a business object in app_code
3. Make a new page
4. Add an ObjectDataSource to the page

…then everything is fine and the ObjectDataSource shows the business object as a choice in the dropdown.

HOWEVER….

If I create a business object (even a simple one) in app_code in a DotNetNuke project then none of the ObjectDataSource controls can see this class.

Why?

 

It is likely because of the attributes on the methods.  Try adding attributes like what I am pasting below to your methods and see if the methods show up.  If some code uses them and others don’t the rules get a little strange.  best to always use the attributes
and your stuff will always work.  I’ve got more complete examples of correctly marked ODS attributes on my blog.

http://peterkellner.net

 

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using System.IO;

/// <summary>
/// Summary description for ODS
/// </summary>
///
[DataObject(true)]  // This attribute allows the ObjectDataSource wizard to see this class
public class ODS //: ISerializable
{

    private List<BusinessObject> listBusinessObject = new List<BusinessObject>();
    private string fileNameToSerializeTo;
   
 public ODS()
    {
        fileNameToSerializeTo = "c:\temp\ODS.txt";
        System.Xml.Serialization.XmlSerializer xmls = new System.Xml.Serialization.XmlSerializer(new List<BusinessObject>().GetType());
        StreamReader sr = new StreamReader(fileNameToSerializeTo);
        listBusinessObject = (List < BusinessObject >) xmls.Deserialize(sr);
        sr.Close();
 }

    [DataObjectMethod(DataObjectMethodType.Select,true)]
     public List<BusinessObject> GetMembers()
    {
        //
        return listBusinessObject;

        //List<BusinessObject> lbo = new List<BusinessObject>();
        //lbo.Add(new BusinessObject(1001,"Peter Kellner","peter@peterkellner.net"));
        //lbo.Add(new BusinessObject(1002,"John Smith","John@Microsoft.com"));
        //lbo.Add(new BusinessObject(1003,"David Nadler","David@IBM.com"));
        //return lbo;

    }

    [DataObjectMethod(DataObjectMethodType.Select, false)]
    public List<BusinessObject> GetMembers(int Id)
    {

        List<BusinessObject> listBusinessObjectFiltered = new List<BusinessObject>();
        foreach (BusinessObject currentBusinessObject in listBusinessObject)
        {
            if (currentBusinessObject.Id == Id)
            {
                listBusinessObjectFiltered.Add(currentBusinessObject);
            }
        }
        return listBusinessObjectFiltered;
    }

    [DataObjectMethod(DataObjectMethodType.Insert, true)]
    public void Insert(int Id,string Name,string Email)
    {
        bool foundDuplicate = false;
        int currentMax = 0;
        foreach (BusinessObject currentBusinessObject in listBusinessObject)
        {
            if (currentMax < currentBusinessObject.Id)
            {
                currentMax = currentBusinessObject.Id;
            }

            if (currentBusinessObject.Id == Id)
            {
                foundDuplicate = true;
            }
        }
        if (foundDuplicate == true || Id < 0)
        {
            listBusinessObject.Add(new BusinessObject(currentMax+1, Name, Email));
        }
        else
        {
            listBusinessObject.Add(new BusinessObject(Id, Name, Email));
        }
        SerializeList(fileNameToSerializeTo);
       
    }

    [DataObjectMethod(DataObjectMethodType.Delete, true)]
    public void Delete(int Id)
    {
        BusinessObject foundBusinessObject = null;
        foreach (BusinessObject currentBusinessObject in listBusinessObject)
        {
            if (currentBusinessObject.Id == Id)
            {
                foundBusinessObject = currentBusinessObject;
            }
        }
        if (foundBusinessObject != null)
        {
            listBusinessObject.Remove(foundBusinessObject);
        }
        SerializeList(fileNameToSerializeTo);
    }

    [DataObjectMethod(DataObjectMethodType.Update, true)]
    public void Update(int Id,string Name,string Email)
    {
        BusinessObject foundBusinessObject = null;
        foreach (BusinessObject currentBusinessObject in listBusinessObject)
        {
            if (currentBusinessObject.Id == Id)
            {
                foundBusinessObject = currentBusinessObject;
            }
        }
        if (foundBusinessObject != null)
        {
            listBusinessObject.Remove(foundBusinessObject);
            listBusinessObject.Add(new BusinessObject(Id, Name, Email));
        }
        SerializeList(fileNameToSerializeTo);
    }

    private  void SerializeList(string fileName)
    {
        System.Xml.Serialization.XmlSerializer xmls = new System.Xml.Serialization.XmlSerializer(new List<BusinessObject>().GetType());
        StreamWriter sw = new StreamWriter(fileName);
        xmls.Serialize(sw,listBusinessObject);
        sw.Close();
    }

}

 

 

Peter,

I understand what the attributes do, but it doesn’t solve the problem. I get the same issue. HAve you tried this in DNN 4.0? I added your class to the app_code directory, but it still doesn’t show up in the dropdown for an objectdatasource.

If you can get this to work in DNN 4.0, please let me know. This is the only project in which it doesn’t function properly.

 

Thanks for your help.

Sorry, I don’t know DNN.  I was hoping you were suffering from the attribute problem but it sounds like not.

Okay, I may have figured out how VS2005 works with ObjectDataSource.

It appears that if I have public classes in app_code and also DLLs with public classes in bin then VS2005 ignores all the classes in app_code and only uses bin (even though they are different classes).

I can use bin OR app_dev, but not both.

 

good to know.  I would have thought they all would have showed up.  Probably worth reporting as a bug just to find out how things really work. (or are suppose to work)
This post fixed my problem – thanks! If I have a dll in Bin, the adapters dont show up but if I exclude the dll from the project then they do!

Is there a way of having both in the same project? can I just put the dll in the App_Code directory?

thanks,

lukemack.

Does anyone know of a way to get this to work with both App-Code and Bin folders present?

I have the same problem too and thanks for this post! Took me a lot of time though…

A quick workaround I’ve been using is to create the ODS then manually insert the typename. Once that’s in place you can configure it as expected.

This work around does not work for me. My problem is that the ObjectDataSource can not read from the Bin Directory. This seemed to work until I upgraded to VS 2005 SP1. I am really stuck here. I have dozens of objects I can no longer see via the ObjectDataSource.
I have seen other post where this is described as a bug and several other work arounds suggested. None of which have been successful for me. Help.

Has anyone get to a place and find out how to solve this problem?

I’m having the same issue, this started after I instaled SP1.

Thanks.

I am seeing a very similar problem.   I am inheriting a web site that has a bin folder and no app_code folder.  I created a new dataset object and it tossed it in the root directory and did not prompt me to even create a app_code folder to put it in.. I
manually created the folder and put the xsd in that folder and now when I attempt to compile the project I get the following message:

The directory ‘/App_Code/’ is not allowed because the application is precompiled.

My xsd has all of my table adapters created and when I drop a object data source on the page and view the object the table adapters are not in the list only the dlls that are in the bin folder that I have references set to.

Also when I went to create the App_Code folder by right clicking and choosing Add > ASP.NET Folder > App_Code is not even in the list.  So obviously this site is set up as an application different than what I am use to working with.  If anyone has any insight
on what is going on here I would love to hear it. 

Thanks,
Derek

I have same problem with DNN. No objects show up. Also the configure does not work when I put in the name of my objects in the object’s members. Is the somebody of MS present or do I have to spend 400 USD for a MSDN ticket? Maybe we can pool for the costs :-(.

Have exactly the same issue here:
(http://www.dotnetnuke.com/Community/Forums/tabid/795/forumid/111/threadid/136089/scope/posts/Default.aspx)

Anyone found a solution (not having fun either :).
(http://www.dotnetnuke.com/Community/Forums/tabid/795/forumid/111/threadid/136089/scope/posts/Default.aspx)

Many thanks…!

 p.s.

My code is as below

<ComponentModel.DataObjectAttribute()> _ ‘ Not sure if this line is needed or not, doesn’t work either way anyway
Public Class WebsiteDirectoryController

<ComponentModel.DataObjectMethod(ComponentModel.DataObjectMethodType.Insert,
True)> _
Public Shared
Sub WebsiteDetails_Insert(ByVal WebsiteDirectoryInfo
As WebsiteDirectoryInfo)DataProvider.Instance().ExecuteNonQuery("WebsiteDetails_Insert", WebsiteDirectoryInfo.ModuleId,
_

GetNull(WebsiteDirectoryInfo.CreatedByUser), WebsiteDirectoryInfo.CreatedDate, GetNull(WebsiteDirectoryInfo.CreatedByUserName), _

GetNull(WebsiteDirectoryInfo.SiteURL), GetNull(WebsiteDirectoryInfo.SiteThumbnailURL), GetNull(WebsiteDirectoryInfo.SiteName), _

GetNull(WebsiteDirectoryInfo.SiteDescription))

End Sub

<ComponentModel.DataObjectMethod(ComponentModel.DataObjectMethodType.Delete,
True)> _
Public Shared
Sub WebsiteDetails_Delete(ByVal WebsiteDirectoryInfo
As WebsiteDirectoryInfo)

DataProvider.Instance().ExecuteNonQuery("WebsiteDetails_Delete", WebsiteDirectoryInfo.ItemId)

End Sub

<ComponentModel.DataObjectMethod(ComponentModel.DataObjectMethodType.Update,
True)> _
Public Shared
Sub WebsiteDetails_Update(ByVal WebsiteDirectoryInfo
As WebsiteDirectoryInfo)DataProvider.Instance().ExecuteNonQuery("WebsiteDetails_Insert", WebsiteDirectoryInfo.ItemId,
WebsiteDirectoryInfo.ModuleId, _

GetNull(WebsiteDirectoryInfo.CreatedByUser), WebsiteDirectoryInfo.CreatedDate, GetNull(WebsiteDirectoryInfo.CreatedByUserName), _

GetNull(WebsiteDirectoryInfo.SiteURL), GetNull(WebsiteDirectoryInfo.SiteThumbnailURL), GetNull(WebsiteDirectoryInfo.SiteName), _

GetNull(WebsiteDirectoryInfo.SiteDescription))

End Sub

<ComponentModel.DataObjectMethod(ComponentModel.DataObjectMethodType.Select,
True)> _
Public Shared
Function WebsiteDetails_SelectAll(ByVal ModuleId
As Integer)
As List(Of WebsiteDirectoryInfo)

Return CBO.FillCollection(Of WebsiteDirectoryInfo)(CType(DataProvider.Instance().ExecuteReader("WebsiteDirectoryInfo_SelectAll",
ModuleId), IDataReader))

End Function

End Class

Have exactly the same issue here:
(http://www.dotnetnuke.com/Community/Forums/tabid/795/forumid/111/threadid/136089/scope/posts/Default.aspx)

Anyone found a solution (not having fun either :).
(http://www.dotnetnuke.com/Community/Forums/tabid/795/forumid/111/threadid/136089/scope/posts/Default.aspx)

Many thanks…!

 p.s.

My code is as below

<ComponentModel.DataObjectAttribute()> _ ‘ Not sure if this line is needed or not, doesn’t work either way anyway
Public Class WebsiteDirectoryController

<ComponentModel.DataObjectMethod(ComponentModel.DataObjectMethodType.Insert,
True)> _
Public Shared
Sub WebsiteDetails_Insert(ByVal WebsiteDirectoryInfo
As WebsiteDirectoryInfo)DataProvider.Instance().ExecuteNonQuery("WebsiteDetails_Insert", WebsiteDirectoryInfo.ModuleId,
_

GetNull(WebsiteDirectoryInfo.CreatedByUser), WebsiteDirectoryInfo.CreatedDate, GetNull(WebsiteDirectoryInfo.CreatedByUserName), _

GetNull(WebsiteDirectoryInfo.SiteURL), GetNull(WebsiteDirectoryInfo.SiteThumbnailURL), GetNull(WebsiteDirectoryInfo.SiteName), _

GetNull(WebsiteDirectoryInfo.SiteDescription))

End Sub

<ComponentModel.DataObjectMethod(ComponentModel.DataObjectMethodType.Delete,
True)> _
Public Shared
Sub WebsiteDetails_Delete(ByVal WebsiteDirectoryInfo
As WebsiteDirectoryInfo) DataProvider.Instance().ExecuteNonQuery("WebsiteDetails_Delete", WebsiteDirectoryInfo.ItemId)

End Sub

<ComponentModel.DataObjectMethod(ComponentModel.DataObjectMethodType.Update,
True)> _
Public Shared
Sub WebsiteDetails_Update(ByVal WebsiteDirectoryInfo
As WebsiteDirectoryInfo)DataProvider.Instance().ExecuteNonQuery("WebsiteDetails_Insert", WebsiteDirectoryInfo.ItemId,
WebsiteDirectoryInfo.ModuleId, _

GetNull(WebsiteDirectoryInfo.CreatedByUser), WebsiteDirectoryInfo.CreatedDate, GetNull(WebsiteDirectoryInfo.CreatedByUserName), _

GetNull(WebsiteDirectoryInfo.SiteURL), GetNull(WebsiteDirectoryInfo.SiteThumbnailURL), GetNull(WebsiteDirectoryInfo.SiteName), _

GetNull(WebsiteDirectoryInfo.SiteDescription))

End Sub

<ComponentModel.DataObjectMethod(ComponentModel.DataObjectMethodType.Select,
True)> _
Public Shared
Function WebsiteDetails_SelectAll(ByVal ModuleId
As Integer)
As List(Of WebsiteDirectoryInfo)
Return CBO.FillCollection(Of WebsiteDirectoryInfo)(CType(DataProvider.Instance().ExecuteReader("WebsiteDirectoryInfo_SelectAll",
ModuleId), IDataReader))

End Function

End Class

 Hi all

 I am having the same problem but with ajax enabled or toolkit site. If I use a normal asp.net web site (Template) it works fine. I only have an App_Code folder.

 

 

wstevens@vodamail.co.za

 Hi all

 I am having the same problem but with ajax enabled or toolkit site. If I use a normal asp.net web site (Template) it works fine. I only have an App_Code folder.

 

 

I was also haveing the same issue, for about 10 hours i was trying to figure out why my app_code wasn’t working like before (ajax enable website). So after banging my head reading millions of post i finally came across this, then i got an idea. I put a .vb
class file in the root directory, i was able to access my classes. I like to keep the project clean, so i added a folder called classes(which is what i would put all my stuff in that normally i put in app_code) and added in my class file. without a problem
the fricken thing worked. big sye of relief. So i figured i would just publish it, just to see what VS does with the folder. Sure enough it musta put in in a DLL, cause the damn thing worked.

 

I hope this solves peoples problems cause i fustraded me like crazy

 

ryurdiga 

I believe when you add a class in App-Code it somehow feels the class as a content file. So if you see the properties of the file and change the build action to compile then I believe it would work.

 

Cheers,

Avy

All you need to do is to complie the project and then you will see your classes in the drop down.

I also tried all suggestions in this forum. Finally, I came up with a following.
All you need to do is to change the configuration within the web.config file:

Find the following directive: 

<codeSubDirectories>
        <add directoryName="HTML" />
        <add directoryName="whatever_directory_that_is_causing_troubles" />
</codeSubDirectories>

 and add the line that I marked in bold.

Then "save all" and compile the project.

 

 Hi,

 And what should that directory be then, an example would be nice.

Please take a look into your error. It should be right there.

Nur 

I had the same problem. Here is the solution. Enjoy!

http://adefwebserver.com/DotNetNukeHELP/DNN_Things4Sale/ThingsForSale3.htm

ryurdiga

 

wstevens@vodamail.co.za

 Hi all

 I am having the same problem but with ajax enabled or toolkit site. If I use a normal asp.net web site (Template) it works fine. I only have an App_Code folder.

 

 

I was also haveing the same issue, for about 10 hours i was trying to figure out why my app_code wasn’t working like before (ajax enable website). So after banging my head reading millions of post i finally came across this, then i got an idea. I put a .vb
class file in the root directory, i was able to access my classes. I like to keep the project clean, so i added a folder called classes(which is what i would put all my stuff in that normally i put in app_code) and added in my class file. without a problem
the fricken thing worked. big sye of relief. So i figured i would just publish it, just to see what VS does with the folder. Sure enough it musta put in in a DLL, cause the damn thing worked.

 

I hope this solves peoples problems cause i fustraded me like crazy

 

ryurdiga 

 

 

Could you elaborate on what you describe here?  I know this was a long time ago but this sounds like a problem I am having now.  I have an AJAX web site that was working fine with my classes in App_code until I added the timer control (AJAX Extensions) then
my project when compiled won’t recognize my SessionHandler.vb class in the App_code folder.  Are you saying you added a folder (not asp.net folder) to the root of your project and then moved your classes into it and then your project recognized your classes?

Three steps to correct this whole problem.

1. Go ahead and create the folder App_Code.  Create the class files or add the class files that you want to compile as your business objects in your AJAX Web Application. 

2. Make sure the namespace in your class files is correct for each file.  Remove any
".App_Code" extensions.

3. Set each class file to "compile" in the properties for that class file.  You can see this option by clicking the class file, viewing the properties in the properties explorer window, and changing the Build Action dropdown
list to "Compile."

 

Best of luck,

Matt

[RESOLVED]Assigning data to DataGridView

I am retrieving data from backend & assigning it to datatable called "tJobOutputs".

I want to display all the columns in DGV from this table by using—->> dgvJobOutputs.DataSource = CurrentJob.Tables["tJobOutputs"];

But i want 2 more column to be displayed which are not present in database i.e.,in "tJobOutputs".

how do i achieve it?? i want those columns to be displayed in DGV but i dont want to store those in database..

Is it in another datatable?  If so, you can add multiple datatables to a dataset.  Then use a template column and bind the data to the second datatable.  You will need some sort of relation between them.

This page contains links on how to use datasets, datatables, and datarelations

http://msdn.microsoft.com/en-us/library/ss7fbaez.aspx

No those 2 columns r  not of the same Datatable

we are storing the Id for those Data in the same table.. but not its name…

say Document Id is stored but not its Name in DB. So when i save things in front end, i have fetch that value from that text box and same i that Datagrid of the same "Windows form". so while coding i’m using Dataset to store the values to the backend.

only the ID but not the Name of that element or Column.

So Plz suggest me to do that.. And after showing that in Datagridview i need to delete it insted of saving to the Dataset or DB.

 Hi,

To display data in GridView, you can create a temp custom table which contains all columns, including id, name, etc, and then use this new table to bind  GridView. Or you can add two TemplateFields for additional 2 columns and set its value in GridView’s
RowDataBound event. For more information, see
http://www.asp.net/learn/data-access/tutorial-12-cs.aspx
 and

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowdatabound.aspx

For more information about using ObjectDataSource control, see

http://www.asp.net/learn/data-access/tutorial-16-cs.aspx

 

I look forward to receiving your test results.

 hi,

 just add two columns to the datatable and bind the grid, it will show only in the grid, while doing database operations dont bother about the two columns

 

[RESOLVED]Paramater in Query in Query Wizard

I have a page that loads. When it loads I get some domain information about the user and make access public to the variable holding the information. I need to use that variable as a parameter in the query wizard and do not know how. There are options for
from form and from control and from cookie others, but I am not sure on which to use. Any help?

You can either use a basic Parameter and then set the values yourself in the code behind or you can put your variable in the Session and then use the SessionParameter

Do you happen to have an example? I have not really worked with paramters in a session like you are describing.

Hey what have you got so far? I am not even sure what Query Wizard you are referring to lol, is it for Strongly Typed Data Sets?

<div style="BACKGROUND-COLOR: #ffffff; MARGIN: 8px; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; COLOR: #000000; FONT-SIZE: 12px; -webkit-background-clip: initial; -webkit-background-origin: initial" mce_style="BACKGROUND-COLOR: #ffffff;
MARGIN: 8px; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; COLOR: #000000; FONT-SIZE: 12px; -webkit-background-clip: initial; -webkit-background-origin: initial">

When you have a data source, you click its tag and select configure data source. Once you get to the point where you select the table and fields you would like, select create your own sql statement or load stored proc.

 

</div>

Sorry for the delay.

If you want to put some data into a parameter then just select parameter, leave the default value empty.

Click on the datasource and handle the selecting event.

In there put something like:

protected void ObjectDataSource1_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
    {
        e.InputParameters["ParameterName"] = "Some Value";
    }

See this page for reference:

auto filter drop down box

hi all,

i am researching on this :http://www.heuver.com/agricultural/type:b

basically the above site  search option in the top middle allows you to search  based on  any properties, 

lets assume you have bellow table strcuture in your back end DB

id   Size              Brand          series     

1    3.50-7           BMW            X seris

2    3.50-6           Nissan         t series

3    3.50-10         Nissan         lagoona

and search option allows you to search on forward and backwords search, 

so acording to this site http://www.heuver.com/agricultural/type:b     search option

if you type "bkt 5.50"  thats get highlighted on the filtered search , 

so i am trying to find out how do we implment this  in asp.net,  basically allowing user to search on any fields and any possitions .

some idea’s will be appriciated.,

thanks

In a solution like yours I have followed this approach:

I use FilterExpression:

<SqlDataSource ...
<FilterExpression="(COLUMN_A like '%{0}%' OR COLUMN_B like '%{0}%' ....

<FilterParameters>

<asp:ControlParameter ControlID="txtFilter" PropertyName="Text" />

You can display the results in a GridView (the popup panel). Put this GridView inside an UpdatePanel, and refresh it via jQuery, like this, inside <body> element:

<script type="text/javascript">
    var postbackElement;
    Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginRequest);
    Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pageLoaded);

    function beginRequest(sender, args) {
        postbackElement = args.get_postBackElement();
    }

    function pageLoaded(sender, args) {
         
        var updatedPanels = args.get_panelsUpdated();
        $('#' + '<%= this.txtFilter.ClientID  %>').unbind();
        $('#' + '<%= this.txtFilter.ClientID  %>').keyup(function () {
            <%= Page.ClientScript.GetPostBackEventReference(UpdatePanel_ID, "")%>
        });

        if (typeof (postbackElement) === "undefined") {
            return;
        }
        else {
            for (i = 0; i < updatedPanels.length; i++) {
                var strings = $('#<%= this.txtFilter.ClientID  %>').val().split("%");
                for (k = 0; k < strings.length; k++) {
                    $("#<%= this.GridView1.ClientID  %> > tbody > tr:not(:has(table, th))").highlight(strings[k]);
                }
            }
        }
      
    }  

 
    </script>


in <head> section add reference to:

<script src="../../Javascript/jquery-1.6.4.min.js" type="text/javascript"></script>
<script src="../../Javascript/jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script>
<script src="../../Javascript/jquery.highlight.js" type="text/javascript"></script>

PS: This way,as you can notice, you are able to use only ONE filter parameter. 

In my solution I use multiple filters. You can choose the filter separator character (like SPACE or the % symbol in my case…)

That involves of course rewriting the FilterExpression appropriately, and in .cs code implementing the Data_Filtering event, to 

parse the filter TextBox like so:

protected void ODSData_Filtering(object sender, ObjectDataSourceFilteringEventArgs e)
        {
          
            if (e.ParameterValues[0] != null)
            {
                string filter = e.ParameterValues[0].ToString().ToUpper();
                if (!String.IsNullOrEmpty(filter))
                {
                    string[] split = filter.Split(new Char[] { ' ', '%' });

                    if (split.Count() == 1)
                    {
                        e.ParameterValues[0] = split[0];
                        e.ParameterValues[1] = "";
                    }
                    else if (split.Count() == 2)
                    {
                        e.ParameterValues[0] = split[0];
                        e.ParameterValues[1] = split[1];
                    }
                    else
                    {
                        e.ParameterValues[0] = split[0];
                        e.ParameterValues[1] = split[1];
                    }
                }
            }
        }

hi,

u r solution is not clear to me ,  i am looking at the solution for the top middle  search   box like google auto suggest , 

i am not sure how we use grid view  in here ,  i thought the solution is with  Ajax Auto complete with some  SQL .

bit hard to get my head around this  .

if you could post the full source code then i can understand bit more and try it locally , i havent done this before  , so its bit hard to understand ,

thanks

Ehm… In my solution i use GridView, but you can choose any DataBound control… 

Also a ListView can do.

In this example the user can enter TWO search words (separated by SPACE or % character)

<asp:TextBox ID="txtFilter" runat="server" Width="340px" Font-Size="Large" Height="22px"
            CssClass="filterBox"></asp:TextBox>
<asp:UpdatePanel ID="UpdatePanelRicambi" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:GridView ID="GridView1" runat="server" AllowPaging="True" DataSourceID="ODSData"
                    Width="60%" OnDataBound="GridView1_DataBound" EnablePersistedSelection="True"
                    DataKeyNames="COD_RICAMBIO" AllowSorting="True">
                    <Columns>
                        <asp:CommandField ShowSelectButton="True" />
                    </Columns>
                    <SelectedRowStyle CssClass="grid-selected" />
                 
                </asp:GridView>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnFilter" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>
<asp:ObjectDataSource ID="ODSData" runat="server" EnableCaching="True" OldValuesParameterFormatString="original_{0}"
            OnSelected="ODSData_Selected" OnSelecting="ODSData_Selecting" SelectMethod="GetRicambiWithDisponibilitaByDesc_WithoutParameters"
            TypeName="WebSpace.BusinessLayer.BRicambi" FilterExpression="DES_RICAMBIO like '%{0}%' AND DES_RICAMBIO like '%{1}%'"
            OnFiltering="ODSData_Filtering" CacheKeyDependency="key">
            <FilterParameters>
                <asp:ControlParameter ControlID="txtFilter" PropertyName="Text" />
                <asp:ControlParameter ControlID="txtFilter" PropertyName="Text" />
            </FilterParameters>
        </asp:ObjectDataSource>


hi TheRed,

is that possible to share some more code bhind code with me ?

not sure how you pull data from the database, where us is main event code behind code for load the  data from back end ? ,  and on which point you are filterring the back end records  ?

thanks

hi TheRed,

is that possible to share some more code bhind code with me ?

not sure how you pull data from the database, where us is main event code behind code for load the  data from back end ? ,  and on which point you are filterring the back end records  ?

thanks

The code behind is really only that I have posted (Filtering event)…

The Filtering is done internally by ASP.NET (I think). So you don’t have to code nothing. (A possible drawback is that you have to retrive ALL records from database in the first select, for the filtering to work.)

The code that retrieve the data from the database can be any from as simple as a Select string in SqlDataSource ASPX syntax.

In my case I use an ObjectDataSource instead, that eventually calls the DataLayer metthod like this:

public DataSet GetRicambiWithDisponibilitaByDesc_WithoutParameters()
        {
            dataSet = new DataSet("ricambi");
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandType = CommandType.StoredProcedure;
            sqlCommand.CommandText = "ASP_Get_RICAMBI_WITH_DISP_WITHOUT_PARAMETERS";

            try
            {
                this.OpenConnection();
                sqlCommand.Connection = conConnection;
                sqlDataAdapter = new SqlDataAdapter(sqlCommand);
                sqlDataAdapter.Fill(dataSet, "ricambi");
                this.CloseConnection();
            }
            catch (Exception ex)
            {
               
            }

            return dataSet;
        }

Or with direct SQL:

 public DataSet GetRicambi()
        {
            dataSet = new DataSet("ricambi");
            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.CommandType = CommandType.Text;
            sqlCommand.CommandText = "SELECT [COD_RICAMBIO], [DES_RICAMBIO], [COD_GRUPPO_RICAMBIO], " +
                " [COD_ALTERNATIVO], [COD_UN_MISURA], [F_MAGAZZINO], [DATA_INATTIVO], S.COD_DEPOSITO, S.COD_UBICAZIONE, S.GIACENZA_STOCK " +
                " FROM ANAG_RICAMBI 		LEFT JOIN STOCK  S " +
                " ON S.COD_PRODOTTO = ANAG_RICAMBI.COD_RICAMBIO  Where DATA_INATTIVO Is Null Or DATA_INATTIVO > getdate()";

            //sqlCommand.CommandText += DateTime.Now.ToString("MM/dd/yyyy") + "'";

            try
            {
                this.OpenConnection();
                sqlCommand.Connection = conConnection;
                sqlDataAdapter = new SqlDataAdapter(sqlCommand);
                sqlDataAdapter.Fill(dataSet, "ricambi");
                this.CloseConnection();
            }
            catch (Exception ex)
            {
       
                dataSet = null;
                this.CloseConnection();
 
            }

            return dataSet;
        }

Hi TheRed,

could you please share the full source for code behind ? for the grid view and ObjectDataSource ?

just started replicating your front end code  in to the code behind and got some error.,

thanks

Hi thered,

i just cant find  out what is the connection between text box leave events agaist ObjectDataSource filter option,

how do we trigger the  text leave events in to re-filter option with  ObjectSource ?

really  will help me lot  if i get the full source code for code begind , so that i can play aroud ot .

thanks

The link between txtFilter and UpdatePanel:

function pageLoaded(sender, args) {
         
        var updatedPanels = args.get_panelsUpdated();
        $('#' + '<%= this.txtFilter.ClientID  %>').unbind();
        $('#' + '<%= this.txtFilter.ClientID  %>').keyup(function () {
            <%= Page.ClientScript.GetPostBackEventReference(UpdatePanel_ID, "")%>
        });

The .unbind is just to be sure not to bind two times on post-backs…

On each keyup you have a post-back (and so the automatic Filtering on the GridView/DetailsView/whatever)

ASPX

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CacheKeyDependencyTwice.aspx.cs"
    Inherits="CacheKeyDependencyTwice" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="../../Javascript/jquery-1.6.4.min.js" type="text/javascript"></script>
    <script src="../../Javascript/jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script>
    <script src="../../Javascript/jquery.alerts.js" type="text/javascript"></script>
    <script src="../../Javascript/jquery.highlight.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" runat="server">
    <p>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <br />
    </p>
    <script type="text/javascript">
    var postbackElement;
    Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginRequest);
    Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pageLoaded);

    function beginRequest(sender, args) {
        postbackElement = args.get_postBackElement();
    }


    function pageLoaded(sender, args) {
         
        var updatedPanels = args.get_panelsUpdated();
        $('#' + '<%= this.txtFilter.ClientID  %>').unbind();
        $('#' + '<%= this.txtFilter.ClientID  %>').keyup(function () {
            <%= Page.ClientScript.GetPostBackEventReference(UpdatePanelRicambi, "")%>
        });

        if (typeof (postbackElement) === "undefined") {
            return;
        }
        else {
            for (i = 0; i < updatedPanels.length; i++) {
                var strings = $('#<%= this.txtFilter.ClientID  %>').val().split("%");
                for (k = 0; k < strings.length; k++) {
                    $("#<%= this.GridView1.ClientID  %> > tbody > tr:not(:has(table, th))").highlight(strings[k]);
                }
            }
        }
      
    }  

    </script>
    <div>
        <asp:TextBox ID="txtFilter" runat="server" Width="340px" Font-Size="Large" Height="22px"
            CssClass="filterBox"></asp:TextBox>
        <asp:Button ID="btnFilter" runat="server" Text="Filtra" Style="display: none;" />
        <br />
        <asp:UpdateProgress ID="updPrg1" runat="server" DisplayAfter="200" AssociatedUpdatePanelID="UpdatePanelRicambi"
            DynamicLayout="True">
            <ProgressTemplate>
                <div class="progress">
                    <img src="/Resources/Img/progress-loader.gif" alt="Caricamento" />
                </div>
            </ProgressTemplate>
        </asp:UpdateProgress>
        <br />
        <asp:UpdatePanel ID="UpdatePanelRicambi" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:GridView ID="GridView1" runat="server" AllowPaging="True" DataSourceID="ODSData"
                    Width="60%" OnDataBound="GridView1_DataBound" EnablePersistedSelection="True"
                    DataKeyNames="COD_RICAMBIO" AllowSorting="True">
                    <Columns>
                        <asp:CommandField ShowSelectButton="True" />
                    </Columns>
                    <SelectedRowStyle CssClass="grid-selected" />
                </asp:GridView>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnFilter" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>
        <asp:ObjectDataSource ID="ODSData" runat="server" EnableCaching="True" OldValuesParameterFormatString="original_{0}"
            OnSelected="ODSData_Selected" OnSelecting="ODSData_Selecting" SelectMethod="GetRicambiWithDisponibilitaByDesc_WithoutParameters"
            TypeName="WebSpace.BusinessLayer.BRicambi" FilterExpression="DES_RICAMBIO like '%{0}%' AND DES_RICAMBIO like '%{1}%'"
            OnFiltering="ODSData_Filtering" CacheKeyDependency="key">
            <FilterParameters>
                <asp:ControlParameter ControlID="txtFilter" PropertyName="Text" />
                <asp:ControlParameter ControlID="txtFilter" PropertyName="Text" />
            </FilterParameters>
        </asp:ObjectDataSource>
    </div>
    </form>
</body>
</html>

C#

namespace PagineProva
{
    public partial class CacheKeyDependencyTwice : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Debug.WriteLine(DateTime.Now.ToLongTimeString() + ": Page_Load");
        }
 
        protected void ODSData_Selected(object sender, ObjectDataSourceStatusEventArgs e)
        {
            Debug.WriteLine(DateTime.Now.ToLongTimeString() + ": ODSData_Selected***");
            int  _recordsCount = 0;
      
            if (e.Exception == null)
            {
                if (e.ReturnValue.GetType() == Type.GetType("System.Int32"))
                {
                    _recordsCount = (int) e.ReturnValue;
                }
            }
        }
 
        protected void ODSData_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
        {
            Debug.WriteLine(DateTime.Now.ToLongTimeString() + ": ODSData_Selecting...");
        }
 
        protected void ODSData_Filtering(object sender, ObjectDataSourceFilteringEventArgs e)
        {
            Debug.WriteLine(DateTime.Now.ToLongTimeString() + ": ODSData_Filtering");
 
            if (e.ParameterValues[0] != null)
            {
                string filter = e.ParameterValues[0].ToString().ToUpper();
                if (!String.IsNullOrEmpty(filter))
                {
                    string[] split = filter.Split(new Char[] { ' ', '%' });
 
                    if (split.Count() == 1)
                    {
                        e.ParameterValues[0] = split[0];
                        e.ParameterValues[1] = "";
                    }
                    else if (split.Count() == 2)
                    {
                        e.ParameterValues[0] = split[0];
                        e.ParameterValues[1] = split[1];
                    }
                    else
                    {
                        e.ParameterValues[0] = split[0];
                        e.ParameterValues[1] = split[1];
                    }
                }
            }
        }
}
}


If you want to achieve highlight autocompelete, please check the below link:

http://forums.asp.net/t/1306129.aspx

Hi thered.

i have startd to look your code and  tried to implement your code in locally,

but when i run the code i am getthis this error  always

"The type specified in the TypeName property of ObjectDataSource ‘ODSData’ could not be found."

really dont know what this is all about ,

It’s the Class that contains the method that performs the select query versus database … You have to specify the name of your class.

[RESOLVED]How to track Collapse/ Expand event of AJAX Collapsible Panel Extender to call javascript ?

Hi

I am working with AJAX Panel Collapsable panel extender.

The Panel which is to be collapsed/Expanded using AJAX panel Extender contains one custom control, containing 3 Radio buttons one of them is set checked through a javascript function when page loads. I have kept the default property of AJAX collapsable panel
as Collapsable.

Script for AJAX Collapsible Panel Extender is as follow. 

 <ajax:CollapsiblePanelExtender ID="cpeSOP" runat="Server" CollapseControlID="pnlCollapsable"
   CollapsedSize="0" Collapsed="True" CollapsedImage="~/public/img/arrowRightWhite.gif"
   ExpandControlID="pnlCollapsable" ExpandDirection="Vertical" ExpandedImage="~/public/img/arrowDownWhite.gif"
   ImageControlID="Image1" SuppressPostBack="true" TargetControlID="pnlSearchCriteria">
  </ajax:CollapsiblePanelExtender>

But problem is that when page loads, collapsible panel gets collapsed but it resets the radio buttons in custom control. i.e. First radio button does not get checked. Script for Collpsable panel is as follow. I want to call some javascript code when the
panel is Collapsed or Expanded. Is there any way to track Collapse / Expand event (client side / server side) of AJAX Collapsable Panel Extender ?

 If so it will be my pleaseure to know this as early as possible, as i am fighting on this problem since long time. I searched for this, but found nothing for events.

Thank you.

Sarang Deshpande

Hi,

 Add a BehaviorID to the CollapsiblePanelExtender .

 BehaviorId="collapsibleBehavior"

Use JS Functions to hook onto the Expand and collapse events.

EX:

function pageLoad(sender,args){

$find("collapsibleBehavior").add_expandComplete( expandHandler );

$find("collapsibleBehavior").add_add_collapseComplete( collapseHandler );

}

function expandHandler( sender  , args ){

alert(‘I have expanded’);

}

function collapseHandler( sender  , args ){

alert(‘I have collapsed’);

}

 

Hope this  helps.

If the reply helps you resolve the issue , please mark it as the answer

It worked !!!!!!!

 Thank you very very much. I was searching for this solution since long time. The code given by you is working correctly.

Now i am trying to put this code into serverside using Page.RegisterClientScriptblock()

 

Thanks for the help again.

 

 

I have created one Collapsible panel and this works fine.

Now my problem is that i have 3 of these, and I want all of them to point to expandHandler and collapseHandler, both of my expandHandler and collapseHandler calls a server method through webservice.

 
Since my webservice needs to know which panel is being expanded, i need to pass a reference of the panels (an id, or the control object whatever, i need to identify them). So i attempted passing the sender argument to the server side code, and when i run it,
somehow the javascript gets caught in an infinite stack.

 
Can you help? Thx
 

 
 

Where do i place function pageLoad()? In my javascript?

Where can I find a reference to all of the client-side functionallity for these AJAX Control Toolkit controls?

Can anyone tell me please?

Hello,

 I was trying the above mentioned solution,  but the "$find("collapsibleBehavior")" section is always returning null. I have added this code to my client side PageLoad() function. Am I missing something? Where should the above code be placed since I noticed
you are sending "sender  , args " params to the declared functions?

Thanks in advance.

Rgds.

Yes the alerts "I have collapsed and  expanded " showup, but this is what i am looking for.

I have two collapsiblePanelExtenders opening two different panels on click and need to collapse a panel if expanded before opening the second one.I tried to use your function expandHandler and put a closePanel() method in there as below which didnt work.
Any ideas are appreciated.

function expandHandler( sender , args ){

closePanel() ;

alert(‘I have expanded’);

}

function closePanel()

{

var mp = $("SecondPanel");

if (mp) {

if (mp.style.display !=
"none") {mp.style.display =
"none";

}

else {

mp.style.display = "";

}

}

event.returnValue=false;
return false;

}

Yes in the javascript.

 Hi, Your answer is interesting. Can you please help me to solve this issue in my case.

 

I am using Data List and collapsible panel as shown below. So where do I put the javascript ?

 

<asp:DataList ID="MessagesDataList" SkinID="SubjectBox" runat="server"
                DataSourceID="MessagesObjectDataSource"
                OnItemDataBound="MessagesDataList_ItemDataBound" >
                <ItemTemplate>
                    

                    <div class="subjectboxpanel">
                        <asp:Panel ID="HeaderPanel" runat="server" Width="100%" >
                            

                                <div>
                                    <div class="subjectboxtxt">
                                        <asp:Image ID="MessageBoxImage" runat="server" /> 
                                        <asp:Image ID="MessageTypeImage" runat="server" />  
                                        

                                        <asp:Label ID="SentDateTimeLabel" runat="server"
                                            Text='<%# Eval("SentDateTime") %>' />
                                         - 
                                        <asp:Label ID="TitleLabel" runat="server"
                                            Text='<%# Eval("Title") %>' />
                                    </div>
                                    <div class="subjectboxicon">
                                        <asp:Image ID="CollapsImage" runat="server" ImageUrl="~/images/desc.gif" />
                                    </div>
                                </div>
                        </asp:Panel>
                    </div>
                    

                    <asp:Panel ID="CollapsPanel" runat="server" BackColor="#F2F8FF" Width="100%" Height="100%" >
                        <div style="display:inline-table">
                        <uc3:EstimateView ID="EstimateView1" runat="server" Visible="false" />
                        <uc2:TextMessageView ID="TextMessageView1" runat="server" Visible="false" />
                        <uc1:RequestForProposal ID="ViewRequestForProposal" runat="server" Visible="false" />
                        </div>
                    </asp:Panel>
                    <ajaxControlToolkit:CollapsiblePanelExtender ID="MessageCollapsiblePanelExtender"
                        runat="server" TargetControlID="CollapsPanel" ExpandControlID="HeaderPanel" CollapseControlID="HeaderPanel"
                        SuppressPostBack="true" ImageControlID="CollapsImage" Collapsed="true" ExpandedImage="~/images/top.gif"
                        CollapsedImage="~/images/down.gif" ExpandDirection="Vertical"  />
                </ItemTemplate>
            </asp:DataList>

  

Thanks 

 

Dinesh

Just a quick correction to the original answer to this post:

This line is incorrect: $find("collapsibleBehavior").add_add_collapseComplete( collapseHandler );

It should be this:  $find("collapsibleBehavior").add_collapseComplete( collapseHandler );

Hi, Phani Raj

I tried your code, its fine if I use single CollapsiblePanel on page, but I am using Collapsible panel inside the repeater where this code doen’t work.

How can I make it work inside the repeater.. Please help.

Within the pageLoad function I would place this two lines right before adding the events handlers

$find("collapsibleBehavior").remove_expandComplete(expandHandler);

$find("collapsibleBehavior").remove_collapseComplete(collapseHandler);

 

thanks 

Phanatic

It is really helpful…

Oh Man…this is da Bomb.  Works great.  Only snafu I ran into was not setting SuppressPostBack="true". 
Once I did it worked great.  Thanks