Category Archives: ObjectDataSource

ObjectDataSource

How do I Prevent Postback after a PageMethod (as webmethod) exception?-URGENT!

Split off from

http://forums.asp.net/t/1417300.aspx/1?How+do+I+Prevent+Postback+after+a+PageMethod+as+webmethod+exception+URGENT+

hi there mrmercury..

i’ve the same problem except that i want the page to postback  if the onSuccess callback function gets hit

i’ve listbox (NewModelLstBx) bound to database and a button (RemoveModelLnk) to delete selected item in that listbox .. i want that when i click the delete button a confirm messege popup with selected item text when the user click ok the
button click event triggres and delete the selected item and if the user click  cancle nothing happend.

i could’nt do that in javascript and i thought it’ll be easier with page method but it does’nt work too

this’s my html code

<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
<Scripts>
<asp:ScriptReference Path="~/ConfirmScripts.js" />
</Scripts>
</asp:ScriptManager>

<td valign="top">
<asp:Button ID="AddModelLnk" runat="server" OnClick="AddModelLnk_Click" ValidationGroup="5" Text=">>" CommandName="Insert"/><br />
<asp:Button ID="RemoveModelLnk" runat="server" OnClick="RemoveModelLnk_Click" Text="<<" CommandName="Delete" OnClientClick="ShowConfirm(‘NewModelLstBx’)"/></td>
<td>
<asp:ListBox runat="server" ID="NewModelLstBx" DataSourceID="NewModelDataSource" DataTextField="Model" DataValueField="ModelID" Width="200px" Height="150px"></asp:ListBox>
<asp:ObjectDataSource ID="NewModelDataSource" runat="server" TypeName="DataBaseComponent.ModelFunctions" SelectMethod="GetBrandModels">
<SelectParameters>
<asp:ControlParameter ControlID="NewBrandDL" PropertyName="SelectedValue" Name="BrandID" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>

and this’s my code behind class with the page method and the button click event

public partial class _Default : System.Web.UI.Page
{
[System.Web.Services.WebMethod()]
[System.Web.Script.Services.ScriptMethod()]
public static string ShowConfirmDelete (string ListBoxId)
{
Page web = new _Default();
ListBox ListBx=(ListBox) web.FindControl(ListBoxId);
return ListBx.SelectedItem.Text;
}

protected void RemoveModelLnk_Click(object sender, EventArgs e)
{
if (NewModelLstBx.SelectedItem == null) NewBrandModelInfoLbl.Text = "select the model first";
else
{
if (ModelFunc.HasMatchesDevices(Convert.ToInt32(NewModelLstBx.SelectedValue)))
NewBrandModelInfoLbl.Text = "u cant delete this model";
else
{
int result = ModelFunc.DeleteModel(Convert.ToInt32(NewModelLstBx.SelectedValue));
if (result > 0)
{
NewModelLstBx.DataBind();
ModelDL.DataBind();
DropDownList InsertModelDL = (DropDownList)InsertNewDeviceFV.FindControl("InsertModelDL");
InsertModelDL.DataBind();
AddModelTxt.Text = "";
NewBrandModelInfoLbl.ForeColor = System.Drawing.Color.Green;
NewBrandModelInfoLbl.Text = "model has deleted succssesfuly";
}
}
}
}

and this’s my javascript code

function ShowConfirm(LisBoxId) {
PageMethods.ShowConfirmDelete(ListBoxId, OnSucceeded);
}
function OnSucceeded(result) {
confirm("are you sure that you want to delete "+result+" model");
}

i really dont know where exactly my mistake is ..is’t in the client code or i did mistake in the page method,, or where exactly

can u help me plzzzzz

[RESOLVED]Entity DataSource in .NET 4.5

I am looking in to the Application Compatability of .NET 4.5.I am looking for ASP.NET breaking changes.

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

 I want to understand what is that mean.

I am able to see the data getting populated without explictly calling DataBind in Page.LoadComplete event.

Can some one help in identifying the different between .NET 4.0 and 4.5 for this control.

 

System.Web.UI.WebControls.EntityDataSource control

The Page.LoadComplete event no longer causes the
System.Web.UI.WebControls.EntityDataSource control to invoke data binding for changes to create/update/delete parameters.

This change eliminates an extraneous trip to the database, prevents the values of controls from being reset, and produces behavior that is consistent with other data controls, such as
SqlDataSource and
ObjectDataSource. This change produces different behavior in the unlikely event that applications rely on invoking data binding in the
Page.LoadComplete event.

 

 

 

Hi vijayarul,

Thanks for posting!

As we know,Page.LoadComplete event will raise after control events.

This is described in MSDN:

“Raised at the end of the event-handling stage.

Use this event for tasks that require that all other controls on the page be loaded.

”, actually, we usually do some setting about page control.

About WebFrom lifecycle, you can refer to this link:

http://msdn.microsoft.com/en-us/library/ms178472%28v=vs.100%29.aspx

About your doubt, the MSDN have clearly described:

“The
Page.LoadComplete
event no longer causes the
System.Web.UI.WebControls.EntityDataSource
control to invoke data binding for changes to create/update/delete parameters.”

It says that we may set the create/update/delete parameters of
EntityDataSource
control in
Page.LoadComplete
event , if we do it in NET4.0, after
Page.LoadComplete
event,  the
EntityDataSource
control will once again retrieve data from db,  but in NET4.5, we will retrieve data from the control cache and send the data into the control like GridView control, the change eliminates an extraneous trip to the database.

If you still have any problem, please let me know.

Thanks!

[RESOLVED]How To Bind DataTable to AjaxCombo Box

Hi All

Im Trying to Bind Dataset To Ajax Combobox By using Below code

<asp:ComboBox ID="cmbClientnames" runat="server" DropDownStyle="DropDownList">
    </asp:ComboBox>
 public System.Data.DataSet GetClientNames()
    {
        System.Data.DataSet dsClients = service.GetAllClientNamesAndIds();
        if (dsClients.Tables[0].Rows.Count > 0)
        {
          


            return dsClients;
        }
        else
        {
            dsClients = null;
        }
        return dsClients;
    }
  System.Data.DataSet DsClientnames = GetClientNames();
            cmbClientnames.DataTextField = "cl_name";
            cmbClientnames.DataValueField = "cl_id";
            cmbClientnames.DataSource = DsClientnames.Tables[0].Columns[1]; here im getting Error 
Data source is an invalid type.  It must be either an IListSource, IEnumerable, or IDataSource.

how to convert dataset data to IListSource or IEnumerable
Thanks In Advance

you have to do like below i think

cmbClientnames.DataSource = DsClientnames.Tables[0];

and you may use objectdatasource to bend it

and here some useful link

http://asp-net-example.blogspot.com/2011/02/ajax-combobox-how-to-set-change_8363.html

VWB 2008 Express questions

Was trying "Scott’s ToDo List" video tutorial and notice something wierd about
VWD2008 Express. On the Default,aspx, at source mode, I clicked on the
ObjectDataSource object, the Properties panel does not show the
Events button. I switched over to Design mode, clicked the
ObjectDataSource object and the Events button showed up. From then on, clicking the same
ObjectDataSource object in either source or Design mode will show the
Events button on the Properties panel. Is this a bug of
VWD2008 Express?

 Another thing, double clicking on a aspx file in Source or
Design
mode  displays the codebehind .cs file with a
Page_Load
. How do I get the Event button to show up for the
Page object in the Properties panel? For example, I wanted VWD to auto generate the "protected
void Page_Preinit(object sender,
EventArgs
e)" handler, how do I do it?

 nay help or advice is much appreciated.

knng

Is this a bug of VWD2008 Express?

No, but it seems like one. it’s a performance optimization. The Visual Studio team decided that when in source view, some of the features would not show up until the user explicitly used the designer. Switching to the designer view "enables" designer required
features for a page, and hence also work in the source view.

knng

How do I get the Event button to show up for the Page object in the
Properties panel? For example, I wanted VWD to auto generate the "protected
void Page_Preinit(object sender,
EventArgs
e)" handler, how do I do it?

 

Oddly enough I couldn’t figure out a way to do it – I seem to recall that existing in previous versions of studio.

Thank you, Kevin.

Yes. In the video tutorial, Joe was able to choose the Page object type from a Dropdown listbox above the code editor and then move over to the events Dropdown listbox on the right to select the list of events pertaining to the
Page object. He was using VWD 2005 Express though. I couldn’t replicate that in
VWD2008 Express.

 I search around the internet and there were some who says if the code is not on a code behind .cs page but inline with the html, then the object listbox above code editor would be populated. I tried that, still didn’t work. Another search says that
VWD 2008 Express’
Intellisense could do it if you start type "override protected void …." but when I get to the
Page object, the Intellisense stops.

Another discovery. In another VWD 2008 Express video by Joe Stagner, I noticed he could access the
Page object and Events from the listboxes above the code editor. I realized that he is using VB while I was trying out in C#. I switched over to VB and what do you know? The
Object Type and Events listbox above the code editor came to live! Shouldn’t working in C# and VB be the same?

[RESOLVED]Data Binding?

I need clarification on what is meant by data binding whenever it is referred in the documentaton and knowledgebase articles.

Say, for a DropdownList control, Is populating it from a datasource (sqldatasource, objectdatasource etc) is databinding ?

Or, setting its SelectedValue to a value is databinding, for example by using the <%# Bind("field") %> syntax.

Which one is it?

Hi,

DataBinding: We may use data binding to fill lists with selectable items from an imported data source, like a database, an XML file, or a script.

However, with data binding we may use a separate source, like a database, an XML file, or a script to fill the list with selectable items.

By using an imported source, the data is separated from the HTML, and any changes to the items are made in the separate data source.

Refer below link also

http://support.microsoft.com/kb/307860

No, as per me binding means connecting the data of the database to the control(e.g DropDownList).

data binding means you can bind your control with persistent data

http://dotprogramming.blogspot.in/2013/04/how-to-bind-gridview-using-adonet.html

hello

refer to link for example how to bind drop dwon from database

 http://simplyaspnet.blogspot.in/2013/07/how-to-populate-dropdown-using-database.html

thank

manish

Thank you for all the responses, but I am sorry to say , none of them directly addresses my question. I gave the DropdownList just as an example. The term "Data Binding" is loosely used in various articles. I need an official definition. The question still
remains. Is populating ListItems in the control from a datasource is called  data binding, Or setting its selectedvalue to a value from another datasource is called data binding. Or is it both?

Thanks.

Both i guess, http://support.microsoft.com/kb/307860

Thanks oned_gk.

So, if I have a DropDownList (ddl) in a Gridview. Then, will the DataBinding event of that ddl be called when the ddl is being populated, Or when it’s SelectedValue is being set to Gridview’s datasource field?

binding simply means, tyings two things, so a generic term, but in Asp.Net world it means, tying your data object (Dataset,Table,DataReader, or even any custom data type) to GUI element (datagrid, dataList, Dropdownlist, textbox or even check box). in bindling
event asp.net links the fields for your data objects to the fields of UI elements. for example Table.NameColum to map to GridView.Colum1 etc. for details plz look at the link below.

http://msdn.microsoft.com/en-us/magazine/cc301536.aspx

So, the scenario I presented in response to oned_gk, the DataBinding event will be raised when the SelectedValue of the DropDownList is set to the parent GridView’s datafield? and not when the DropdownList has been populated from a separate datasource? 

There are two data binding there, DropDownList data binding and GridView (row) data binding.

hello

if in control data is coming  drom database then it is datadinding 

here is msdn articale about databinding

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

http://www.w3schools.com/aspnet/aspnet_databinding.asp

thanks

manish

oned_gk.

The Databinding event I was referring to was raised on the DropdownList (ddl). But wthin it I wanted to know if it was caused by ddl populating Or while its SelecteValue being set.

Thanks.

Manish, thanks for the links.

The first one is a WPF article. It seems like they consider both the populating of the DropdownList (ddl) and setting its SelectedValue as databinding. I "hope" the same concept is being carried over to the ASP.Net Webform context, whenever they talk about
databinding , but I’m not sure.

The second link is not an official Microsoft article.

Thanks any way.

In GridView context, databinding event when SelectedValue being set.

How can I cancel a Databinding event in GridView after DataSource_Selected?

Hi, here’s my scenario:

-
Gridview

bound to an ObjectDataSource (WebService)

- My webservice catches a connection exception, fills a special table containing exception details

- In ObjectDataSource_Selected
event

handler I find out the exception has occured and alert the user

Now I want to prevent the
GridView
_DataBinding
event
from occurring because I know I have no data to display…

… is there a simple way? Something similar to a comfortable:

  

protected
void GridView2_DataBinding(object
sender, EventArgs
e)

{

       if  (something) 

            e.Cancel =
true;

 

}

 

Thanks in advance

Stefano

Sure, create a boolean value at page level called DataLoadSuccessful or something similar. Set this to true or false in your ObjectDataSource_Selected handler and then in the GridView2_DataBinding only perform a bind if the variable is true. 

ParrotBoy

Sure, create a boolean value at page level called DataLoadSuccessful or something similar. Set this to true or false in your ObjectDataSource_Selected handler and then in the GridView2_DataBinding only perform a bind if the variable is true. 

Thanks a lot for your reply,

but my problem is: how can I prevent Databinding from happening?

I mean: GridView_Databinding handles what happens just before the binding occurs; I don’t explicitly call GridView.DataBind() there.

So I cannot avoid it to be called.

 

Stefano Piva

Hi, here’s my scenario:

-
Gridview

bound to an ObjectDataSource (WebService)

- My webservice catches a connection exception, fills a special table containing exception details

- In ObjectDataSource_Selected
event

handler I find out the exception has occured and alert the user

Now I want to prevent the
GridView
_DataBinding
event
from occurring because I know I have no data to display…

… is there a simple way? Something similar to a comfortable:

  

protected
void GridView2_DataBinding(object
sender, EventArgs
e)

{

       if  (something) 

            e.Cancel =
true;

 

}

 

Thanks in advance

Stefano

Can’t you just set the visibility of your GridView to False in this case?

ecbruck

Can’t you just set the visibility of your GridView to False in this case?

I want to stop Databinding because the connection to my database failed and instead of the data to fill the DataGrid table, the returned Dataset contains an exception message. This causes the application to crash because of the diferent colums contained
in the Dataset. What will happen if I set visibility to false? Does that stop the binding process?

I’ll try as soon as possible, that is on monday when I’ll be back to my office.

Thanks for replying.

Stefano

 

As he told you before turning off the visible propertyu should solve your problems for now.

I did the same for a while and it worked.

norchnou

As he told you before turning off the visible propertyu should solve your problems for now.

I did the same for a while and it worked.

 

Well, then… I’ll try this solution on monday.

Thanks a lot.

Stefano

 

ecbruck

Can’t you just set the visibility of your GridView to False in this case?

I tried this solution but… no way: the behavior remains the same.
It still tries to fill the gridview with data that the binding process doesn’t find in the returned Dataset and crashes. 

The only solution I see now is filling a fake table inside the Dataset with void data for all the columns my gridview expects to find.
But I really don’t like this way because of the quite high number of columns I have and because this adds another rigidity point, another piece of code I have to manage every time I add something to my table.

Any other idea?

Stefano

 

If I got your problem right, then you can Cancel the event in the ObjectDataSource_Selecting 
event itself.

That event has e.cancel so if you get an exception in the web service at this event , you can cancel the
Selection itself, which in turn will cancel the grid binding.

Where as if you get an exception after this (i.e  ObjectDataSource_Selected
event) its going to be difficult :(.
 

Hope this helps!!

Manu

 

 Hi,

 

I had the same problem, and I resolved like this.

 

     protected void ObjectDataSource1_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
    {
        if( –condition– == true )
            e.Cancel = true;
    }

 

Maybe this could help you.

 

 

I had a similiar problem where my gridview producted an error when I passed in an invalid parameter. (Invalid format for a date)

My quick solution was to use a Try Catch block.

I had two textboxes, one for a start date and one for an end date. These two were providing parameter values for the WHERE section for the SELECT statement for my GridView. On a postback for each one, the Gridview databinds. If the date is not valid, it
fails and produces an error.

To keep the user from getting an error page, I used a Try Catch block.

    Protected Sub EndDateTXT_TextChanged(sender As Object, e As EventArgs) Handles EndDateTXT.TextChanged
        ErrLAB.Text = ""
        Try
            EventsGV.DataBind()
        Catch ex As Exception
            ErrLAB.Text = "End date was entered incorrectly"       ‘This is optional. I just wanted to let the user know what was going on.
        End Try
    End Sub

The Try Catch block prevents you from seeing an error page.

Using business objects as data source for MS Report rdlcs with WAPs

Since there is no App_Code directory, I am unable to get my generics class to appear in the datasources for an rdlc that I create in my WAP project. 

I think there might be some limitation where we cannot use generics business objects as the datasource or reports since the WAP has no App_Code folder where the class must normally reside for the reporting datasources to pick it up as a datasource.

Any thoughts?  This will prevent my company from moving to 2005!

Here is what someone else used to work around the problem:

  1. <div class=MsoNormal> Drop an ObjectDataSource on the form with the ReportViewer.</div>
  2. <div class=MsoNormal>Configure the ODS to use the TableAdapter associated with the source DataSet.</div>
  3. <div class=MsoNormal>In the Misc->LocalReport properties for the ReportViewer, select DataSources and click the ellipsis.</div>
  4. <div class=MsoNormal>In the ReportDataSource Collection Editor, click the Add button.</div>
  5. <div class=MsoNormal>In the properties for the new ReportDataSource, specify <DataSet>_<table> as the value for the Name property and the ID of the ODS as the value for the DataSourceId property.</div>

 This results in the following ObjectDataSource tag:

 <asp:ObjectDataSource
ID="ObjectDataSource1"
runat="server"
OldValuesParameterFormatString
="original_{0}"
   
SelectMethod
="GetData"
TypeName
="ReportViewerCrash.DataSet1TableAdapters.databasesTableAdapter">
</asp:ObjectDataSource>

 

And the following ReportViewer tag: 

   
<
rsweb:ReportViewer
ID="ReportViewer1"
runat="server"
Font-Names
="Verdana"
Font-Size
="8pt" Height="400px"
Width="400px">
       
<
LocalReport ReportEmbeddedResource="ReportViewerCrash.Report1.rdlc"
ReportPath="Report1.rdlc">
           
<DataSources>
               
<rsweb:ReportDataSource
DataSourceId="ObjectDataSource1"
Name="DataSet1_databases"
/>
           
</DataSources>
       
</
LocalReport>    
   
</
rsweb:ReportViewer>

 

Hope this helps,

Brad.

The problem with this is you are creating a business object datasource from a dataset.

My approach is using a class that returns a generics class of my class type.  This normally is autodetected once compiled in a web site’s App_Code folder when you open an rdlc and look at the website datasource window.

It was confirmed that this is a bug with WAP’s that cannot be addressed until SP1.  The bug is the WebsiteDatasource window does not appear or update with the WAP generics classes.  I was told they are trying to find a workaround and will keep me posted.

I am correct in saying you are creating a dataset to bind to correct?  This is not going to work for the generics report object datasource approach right?

Greg

Hi Greg,

Were you able to resolve this issue? I am also having the same issue. I have a ASP.net Web application (and not a web site) and I want my classes as the data source for the report, but the classes do not show up in the data source window. I need to have
a report and bind to my business objects..

Your response really appreciated.

 

Report Designer Issues?

I rebuilt my computer and installed the VWD2008 instead of the VWD2005. I upgraded as the report viewer functions for 2008 were finally released. I pulled in a project build under 2005 and let it do it’s upgrading. Now I have issues with the report viewer
functions. I get an error in the developement control ie

Error Creating Control-ReportViewer1

Failed to created public designer ‘Microsoft.Reporting.Webforms.ReportViewer.Webforms, Version 8.0.0.0, Culture=neutral, PubicKey Token=b03f5f7f11d50a3a’

Looking at my web.config file I find two references to Microsoft.ReportViewer. A version 8.0.0.0 and a 9.0.0.0. Do I have a version error which wasn’t corrected in the upgrade?

<assemblies>

<add
assembly="Microsoft.ReportViewer.WebForms,
Version=8.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A
"/>

<add
assembly="Microsoft.ReportViewer.Common,
Version=8.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A
"/>

<add
assembly="Microsoft.ReportViewer.WebForms,
Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A
"/>

<add
assembly="Microsoft.ReportViewer.Common,
Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A
"/></assemblies>

 When I created a new report viewer it tells me

Error Creating Control-ReportViewer1

The server Tag ‘rsweb.ReportViewer’ is ambiguous. Please modify the associated registration that is causing the ambiguity and pick a new tag prefix. 

Any help?

UPDATE: Looking at the web.config file there are two references to Reportviewer version 8 and version 9. When the upgrade originally runs it does nothing to the web.config file and the program
will run fine and all reports can be run but have an error if tried to edit or view in development. If you build a new report with the new report viewer/builder for vwd2008 you will get two instances in the web.config file but will be able to edit in the development-The
problem comes when compiling-so many errors- It appears the reports developed in vwd2005 cause errors when tring to run it vwd2008. I have changed the web.config to a 2008 version and changed all the reports over to 2008 and I still get errors in the aaplication
code which stops it from running. For now I will have to revert back to 2005 until I can figure this out.

I solved the problem by doing the following.

  • <div mce_keep="true">I built another website under vwd2008. Build a dataset and report and report viewer.</div>
  • <div mce_keep="true">I copied the web.config file to a txt.doc</div>
  • <div mce_keep="true">I opened my site with the problems </div>
    • <div mce_keep="true">made a copy of the original web.config </div>
    • <div mce_keep="true">Copied and pasted my saved web.config from my txt.doc file location</div>
    • <div mce_keep="true">opened and copied my connections from my original web.config and pasted to my new web.config.</div>
    • <div mce_keep="true">You then have to go to every report viewer instance and change the reference from 8.0.0.0 to 9.0.0.0 and check your ObjectDataSource for missing parameters ie config the source to make sure its right. You have to fix them all to eliminate
      the errors.</div>
  • <div mce_keep="true">Now I am happy[Yes] and can get the reports to view that I want without pulling my hair out.</div>

[RESOLVED]Use of the designer to bind data and writing code: what are your comments?

I cam from the Woindows Programming back ground and in C# / VB we use semi-Designer to create controls ie. I used Drag and drop option to add controls to the form though we could bound data to control from the designer, I wrote code to bind data to controls.
This is the way I used to write apps. When I move to I found many tutor used the designer to bind data to controls…etc. Should we use the designer to to bind data to control or this is a personal preference? cheers

Its always better to Bind the data in Codebehind rather than in designview.
This will fix a lot of designing efforts.

Hi,

Visual Studio provides many controls to bind data without writing any code, this will make asp.net development fast.

In my opinion, it depends on your requirement. For a little project, I will use designer to bind data this is easy and fast. For large project, especially for team work project, I prefer to write code. For instance, one engineer writes data access code and
another writes data present page.

Besides, using code can let you understand the technology well. You also can work them together. For example, you create data access layer and use ObjectDataSource control to bind data.

For more information, http://www.asp.net/learn/data-access/

 

Thanks.

 

 

using CascadingDropDown with detailsview not update …!

<%@ 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>
    ( ObjectDataSource1 ........)
    
    </form>
</body>
</html>

hi , i used cascadingdropdown  in my page  and  dropdrownlist is controlparameter to select method objectdatasource , but  update detailsview not work  !!!

can select query well , but  update linkbutton in detailsview not work , and delete & insert button  works well …  just  update not work ?? why ???