Category Archives: LinqDataSource

LinqDataSource

[RESOLVED]query extender control

Below is my coding on the query extender control… all working fine but if i want to show a prompt up message said if no record found?

what should i do ? how to do it ?

Coding(HolidaySearch.aspx)

<%@ Page Title="" Language="C#" MasterPageFile="~/SiteAdmin.Master" AutoEventWireup="true" CodeBehind="HolidaySearch.aspx.cs" Inherits="TimeAttendReport.Account.HolidaySearch" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .style3
        {
            width: 766px;
        }
        .style4
        {
            width: 100%;
        }
        .style5
        {
            width: 200px;
        }
        </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div>
        <h2 style="color: Blue">
            Holiday Search:</h2>
    </div>
    <table class="style4">
        <tr>
            <td class="style5">
                Holiday Search:</td>
            <td>
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style5">
                &nbsp;</td>
            <td>
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style5">
                Holiday Name:</td>
            <td>
                <asp:TextBox ID="txtHoliday" runat="server" Height="22px" Width="221px"></asp:TextBox>
            </td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style5">
                &nbsp;</td>
            <td>
                <asp:Button ID="Button2" runat="server" Text="Search" />
            </td>
            <td>
                &nbsp;</td>
        </tr>
    </table>
      <div>
      <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
            AutoGenerateColumns="False" CellPadding="4" DataSourceID="LinqDataSource1"
            ForeColor="#333333" GridLines="None" PageSize="8" Width="531px"
              style="text-align: center; background-color: #0000FF;">
            <AlternatingRowStyle BackColor="White" />
            <Columns>
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID"
                    InsertVisible="False" />
                <asp:BoundField DataField="Holiday1" HeaderText="Holiday1"
                    SortExpression="Holiday1" />
                <asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date" />
                <asp:BoundField DataField="State" HeaderText="State" SortExpression="State" />
            </Columns>
            <EditRowStyle BackColor="#2461BF" />
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#EFF3FB" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <SortedAscendingCellStyle BackColor="#F5F7FB" />
            <SortedAscendingHeaderStyle BackColor="#6D95E1" />
            <SortedDescendingCellStyle BackColor="#E9EBEF" />
            <SortedDescendingHeaderStyle BackColor="#4870BE" />
        </asp:GridView>
            <asp:LinqDataSource ID="LinqDataSource1" runat="server"
              ContextTypeName="TimeAttendReport.App_Code.DataClasses1DataContext"
              EnableDelete="True" EnableInsert="True" EnableUpdate="True" EntityTypeName=""
              TableName="Holidays">
          </asp:LinqDataSource>
          <asp:QueryExtender ID="QueryExtender1" runat="server" TargetControlID="LinqDataSource1">
          <asp:SearchExpression DataFields="Holiday1" SearchType ="StartsWith">
          <asp:ControlParameter ControlID = "txtHoliday" />
          </asp:SearchExpression>
          </asp:QueryExtender>
            </div>
</asp:Content>

In Server side (C#) during gridview databind you can check if datatsource is empty means no records you can show message or

Use the GridView Empty Data Template.  See the example here:

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.emptydatatemplate%28VS.80%29.aspx

the GridView dislay its EmptyTemplate content if there is no data , you can configure the gridView to Display that message by setting theEmptyDataTemplate of the
gridview as foolwos :

<asp:GridView ID="GridView1" runat="server">
        <EmptyDataTemplate>
            No Data Exists
        </EmptyDataTemplate>
        <Columns >
        ......
        </Columns>
    </asp:GridView>


[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!

Basic Linq to SQL Question

So, my question is: how do you get the DataSource Configuration Wizard to recognize the DataContext class when there is no App_Code folder in a WAP project?  I’ve tried creating the DataContext using the VS Relational Designer (.dbml) which produces the
correct DataContext and DB entity classes, but the datasource config wizard won’t recognize it.  If I hard code the ContextTypeName in the control markup for the LinqDataSource object, then the wizard shows it on its first page in the datasource selction combobox,
but then I get an error saying that the DataContext object can’t be found in the App_Code folder (not surprising), or in any compiled assembly.  I’ve also tried creating a separate class library DLL for the DBML stuff and then referencing it in my WAP project,
but I still get the same error in the datasource config wizard.

This is really frustrating me.  If I open the entire DotNetNuke web site as a VS project, then I can add the DBML stuff in its App_Code folder and my module in the DesktopModules folder and that all works nicely, but I want to keep my module as a separate
project.  Also, creating the Module folder manually under DotNetNuke doesn’t give me the .dnn file and other such goodies that the DNN project template generates, so I can’t do any localization stuff (maybe I can create the .dnn file manually, I haven’t tried
that yet.)

Is there any way to resolve this seeming impasse between WAP and the LinqDataSource config wizard?

Ed

VS2010 : QueryExtender generating too many querys

Hi,

I created a simple scenario :

  • One dropdownlist with countries (from linqdatasource)
  • One gridview with customers (from linqdatasource)
  • One queryextender filtering the gridview(linqdatasource) based on the dropdownlist.

The result is very, very strange : While the first linqdatasource is filling the dropdownlist, for each country added in the dropdownlist the queryextender generate a query filtering customers by this country. As a result, the database receive a lot of queries,
much more than I would like to (I saw the queries in sql profiler)

The question : Did I do something wrong or should I register this in connect ?

The code :

<asp:LinqDataSource ID="LinqDataSource2" runat="server"
            ContextTypeName="site1.NorthDataContext" EntityTypeName="" GroupBy="Country"
            Select="new (key as Country, it as Customers)" TableName="Customers">
        </asp:LinqDataSource>
        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
            DataSourceID="LinqDataSource2" DataTextField="Country" DataValueField="Country">
        </asp:DropDownList>
        <br />
        <asp:LinqDataSource ID="LinqDataSource1" runat="server"
            ContextTypeName="site1.NorthDataContext" EnableDelete="True"
            EnableInsert="True" EnableUpdate="True" EntityTypeName="" TableName="Customers">
        </asp:LinqDataSource>
    <asp:QueryExtender runat="server" TargetControlID="LinqDataSource1">
        <asp:PropertyExpression>
            <asp:ControlParameter ControlID="DropDownList1" Name="Country" />
        </asp:PropertyExpression>
    </asp:QueryExtender>
    </div>
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
        AllowSorting="True" AutoGenerateColumns="False"
        BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px"
        CellPadding="2" DataKeyNames="CustomerID" DataSourceID="LinqDataSource1"
        EnablePersistedSelection="True" ForeColor="Black" GridLines="None">
        <AlternatingRowStyle BackColor="PaleGoldenrod" />
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True"
                ShowSelectButton="True" />
            <asp:BoundField DataField="CustomerID" HeaderText="CustomerID" ReadOnly="True"
                SortExpression="CustomerID" />
            <asp:HyperLinkField DataNavigateUrlFields="CustomerID"
                DataNavigateUrlFormatString="clientes/{0}" DataTextField="CompanyName"
                HeaderText="CompanyName" SortExpression="CompanyName" />
            <asp:BoundField DataField="ContactName" HeaderText="ContactName"
                SortExpression="ContactName" />
            <asp:BoundField DataField="Country" HeaderText="Country"
                SortExpression="Country" />
        </Columns>
        <FooterStyle BackColor="Tan" />
        <HeaderStyle BackColor="Tan" Font-Bold="True" />
        <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue"
            HorizontalAlign="Center" />
        <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
    </asp:GridView>

Thanks !

 

Dennes

 

[RESOLVED]DropDownList has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value

Hi all,

I make a web based program using ASP.NET C#.

I have a textbox named txtAgencyCode and I have
dropdownlist named ddlJono.

dropdownlist ddlJono is linked with LinqDatasource named LinqDSJO


The scenario of the program is when user click dropdownlist ddlJono, it will display data which agencycode = txtAgencyCode

in the code behind, I coded like this :

<asp:LinqDataSource ID="LinqDSJO" runat="server"
                            ContextTypeName="DataClassesDataContext" EntityTypeName=""                             
                            TableName="qryJo_Headers" Select="new (jono)" Where="agencycode = @AgencyCode" >  
                          <WhereParameters>
                             <asp:ControlParameter
                              Name="AgencyCode"                              
                              ControlID="txtAgencyCode"
                              Type="string" />
                          </WhereParameters>                                      
 </asp:LinqDataSource>

But when I run the program, It always shows and error like this below :

‘ddlJono’ has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value’

Does anyone can help me how to solve this error ?

Thank you

Regards,

Sentoso



error is while setting selectedvalue field of dropdown..

u may have done something like this

ddlJono.SelectedValue = "some value"; 

this "some value" is not present in datasource assigned to dropdown… in short, u r trying to select the value of dropdown in code which is not present in the dropdown item’s list

where u r setting dropdown.selectedvalue? can u post that code

hope this helps…

The problem is

You get data from database for ddl selected value = "X"

But the ddl only has items : "A", "B", and "C"

Make sure the ddl also has "X" value.

But common problem you get null value from database

To avoid this set ddl appenddatabound to true and add blank item (null)

<asp:DropDownList ID="ddlJono" runat="server" AppendDataBoundItems="True">
        <asp:ListItem>Blank</asp:ListItem>
    </asp:DropDownList>

Thank you very much for your idea.  I already know the cause, when the program starts I try to set ddlJono.Text = " ".

When I removed that line It works well.

Regards,

Sentoso

Hi all,

Simple Solution for above error is

1] Handle null value in DB sql query to bind dropdownlist  like

Eg:

DECLARE @iCount as INT;

SELECT @iCount = COUNT(*)
FROM
tblJob
WHERE IsActive = 1
AND FunctionId = @FunctionID

IF (@iCount >0)
BEGIN

Select * from
(
SELECT 0 JobId, ‘–Select–’ JobDescription
UNION ALL
SELECT Isnull (JobId,0) as JobId, Isnull (JobDescription,’–Select–’) as JobDescription

FROM tblJob
WHERE IsActive = 1
AND FunctionId = @FunctionID
) aaaaa
ORDER by case when JobDescription = ‘–Select–’ then ‘aaaaaaaa’ else JobDescription end

END
ELSE
BEGIN
Select 0 JobId, ‘–Select–’ JobDescription
END

2] Remove or clear item of dropdownlist before binding it.

Rest it will work smoothly.

Happy Coding !@!Cool 

[RESOLVED]Struggling with GridView filtering and sorting

I’m using a dbml file and a LinqDataSource to populate a gridview with rows from a database view.

I’ve turned on sorting on the grid and used sortexpressions to enable user sorting.

All good so far :-)

I also have a checkbox that I want to filter a specific column. E.g. column displays Yes/No and the checkbox shows rows with the value Yes when ticked and No when not ticked.

I have implemented this by using the CheckChanged event on the checkbox and then filtering the LinqDataSource thus       

        if (chkBox.Checked)
        {
            LinqDataSource1.Where = "Column = "Yes"";
        }
        else
        {
            LinqDataSource1.Where = "Column = "No"";

        }

This code works fine and filters the rows accordingly, however having applied the filter, if I then sort a column the gridview re-initialises the data and I get all rows displayed? I still want the filter to rows yet have them sorted too?I feel I’m missing
something simple here.

Any pointers anyone?

Cheers John

hi JBNZ ,

According to your description, I understand you want to filter and sort the data in
GridView.

I would suggest you to try the following demo: 

Using LinqDataSource With GridView Control

http://weblogs.asp.net/zeeshanhirani/archive/2008/05/01/using-linqdatasource-with-gridview-control.aspx 

Walkthrough: Selecting and Filtering a Subset of Data with the LinqDataSource and GridView Controls

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

Base on GridView

Evonet | Creating a great looking
Gridview with filtering

 If you have any questions please do not hesitate to contact me.

I’ve marked both as answers, whilst no single link gave me my answer, a combination of the information from each link gave me the information required to find a solution.

I didn’t realise the LinqDataSource object was so powerful.

If anyone is wondering I added the code in the CheckChanged event into the Selecting event of the LinqDataSource as well. This then fires every time I sort on a column.

Cheers John

[RESOLVED]FileUpload within a Formview wrapped with UpdatePanel problem

Hi there,

i have the following Formview control which has a FileUpload control in its EditTemplate. If I wrap the control with UpdatePanel the FileUpload control always return False in the HasFile property.

How can I make it work inside an UpdatePanel ?

<asp:FormView ID="FormView1" runat="server" DataKeyNames="id" DataSourceID="LinqDataSource2"
                DefaultMode="Edit" OnItemUpdated="FormView1_ItemUpdated" OnItemUpdating="FormView1_ItemUpdating"
                OnDataBound="FormView1_DataBound">
                <EditItemTemplate>
                    id:
                    <asp:Label ID="idLabel1" runat="server" Text='<%# Eval("id") %>' />
                    <br />
                    cName:
                    <asp:TextBox ID="cNameTextBox" runat="server" Text='<%# Bind("cName") %>' />
                    <br />
                    cEmail:
                    <asp:TextBox ID="cEmailTextBox" runat="server" Text='<%# Bind("cEmail") %>' />
                    <br />
                    cURL:
                    <asp:TextBox ID="cURLTextBox" runat="server" Text='<%# Bind("cURL") %>' />
                    <br />
                    startOn:
                    <asp:TextBox ID="startOnTextBox" runat="server" Text='<%# Bind("startOn") %>' />
                    <br />
                    ShowTill:
                    <asp:TextBox ID="ShowTillTextBox" runat="server" Text='<%# Bind("ShowTill") %>' />
                    <br />
                    file2Show:
                    <asp:FileUpload ID="FileUpload1" runat="server" />
                    <br />
                    prefBox:
                    <asp:TextBox ID="prefBoxTextBox" runat="server" Text='<%# Bind("prefBox") %>' />
                    <br />
                    <asp:LinkButton ID="UpdateButton" ClientIDMode="Static" runat="server" CausesValidation="True"
                        CommandName="Update" Text="Update" />
                    &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False"
                        CommandName="Cancel" Text="Cancel" />
                </EditItemTemplate>
                <InsertItemTemplate>
                    cName:
                    <asp:TextBox ID="cNameTextBox" runat="server" Text='<%# Bind("cName") %>' />
                    <br />
                    cEmail:
                    <asp:TextBox ID="cEmailTextBox" runat="server" Text='<%# Bind("cEmail") %>' />
                    <br />
                    cURL:
                    <asp:TextBox ID="cURLTextBox" runat="server" Text='<%# Bind("cURL") %>' />
                    <br />
                    startOn:
                    <asp:TextBox ID="startOnTextBox" runat="server" Text='<%# Bind("startOn") %>' />
                    <br />
                    ShowTill:
                    <asp:TextBox ID="ShowTillTextBox" runat="server" Text='<%# Bind("ShowTill") %>' />
                    <br />
                    file2Show:
                    <asp:TextBox ID="file2ShowTextBox" runat="server" Text='<%# Bind("file2Show") %>' />
                    <br />
                    prefBox:
                    <asp:TextBox ID="prefBoxTextBox" runat="server" Text='<%# Bind("prefBox") %>' />
                    <br />
                    <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>

FileUpload is not compatible with updatepanel by default. You’d have to set a postbacktrigger for the upload button. 

I understand it is not compatible and I tried to set the UpdatePanel postback trigger to be the Formview UpdateButton with no success.

Any sample of setting the UpdatePanel postback trigger to be the Formview_UpdateButton ?

Set it in code. You can use findcontrol() to find the upload button and set it as postback trigger.

I tried to set the post back trigger it in code as follows but still it does not work for me.

protected void FormView1_DataBound(object sender, EventArgs e)
    {
        if (FormView1.CurrentMode == FormViewMode.Edit)
        {
            LinkButton lb = (LinkButton)FormView1.FindControl("UpdateButton");
            PostBackTrigger upt = new PostBackTrigger();
            upt.ControlID = lb.ID;
            UpdatePanel up = new UpdatePanel();
            up = (UpdatePanel)Page.FindControl("UpdatePanel1");
 
            up.Triggers.Add(upt);

        }
 
    }


Any suggestions ?

cannot locate the explorer

<div class=ForumPostBodyArea> <div class=ForumPostContentText> <div>I have installed the visual studio 2008 express edition</div> <div> </div> <div>before yesterday it run very well. but yesterday I open a web site which I do.When I press the button
Run(the arrow  in the menu) ,happen the error below:</div> <div>
Uable to attach to application ‘WebDev.WebServer.EXE’ (PID:1132) using ’3566F33214E7448′.A debugger is already attached.
Do you want to continue anyway?
                                                           Yes           No</div> <div>if you choose ‘Yes’ button will happen the information below : </div> <div>Unable to start program ‘http://localhost:1256/Ajax/Ajaxexample09.aspx
Cannot locate Microsoft Internet Explorer</div> <div> </div> <div>But when I browser the lonely page, it run good.</div> <div>I have installed the Microsoft Internet Explorer and IIS service. </div>

My computer’s opertion system is xp sp2 

</div></div>

<div> <div id=ctl00_ctl00_bcr_bcr_ctl00_PostList_ctl02_ctl07_ctl00_Container style="DISPLAY: none"> <div class=CommonInlineTagEditor>
<div style="PADDING-TOP: 4px; WHITE-SPACE: nowrap">

Select Tags… SaveCancel

</div></div><input id=ctl00_ctl00_bcr_bcr_ctl00_PostList_ctl02_ctl07_ctl00_AllTags type=hidden value=.net+3.5+framework&.net+3.5+framework&2008+beta+2+sql+data+update+delete+error+problem&2008+beta+2+sql+data+update+delete+error+problem&absolute+position&absolute+position&ajax&ajax&AJAX++VWD+2008&AJAX++VWD+2008&AJax++WebService++Cross-Domain&AJax++WebService++Cross-Domain&AjaxControlTookKit&AjaxControlTookKit&annoying+bugs&annoying+bugs&Application+Service&Application+Service&application+upload&application+upload&ASP&ASP&asp.net&asp.net&asp.net+1.0&asp.net+1.0&asp.net+2.0&asp.net+2.0&asp.net+ajax&asp.net+ajax&ASP.NET+Futures&ASP.NET+Futures&asp.net2.0&asp.net2.0&ASPX&ASPX&auto+position&auto+position&automatic+quote+inserting&automatic+quote+inserting&best+practice&best+practice&Bug&Bug&building+html+strict+web+sites&building+html+strict+web+sites&code+markup&code+markup&copy+rights&copy+rights&copy+web+site&copy+web+site&css&css&CSS+Apply+styles+tab&CSS+Apply+styles+tab&CSS+Styling+Options&CSS+Styling+Options&Data+connection&Data+connection&database&database&datapager&datapager&DataPager+ListView+Orca&DataPager+ListView+Orca&DBML&DBML&delete&delete&design+view&design+view&devenv&devenv&Direction%3dOutput&Direction%3dOutput&DLL&DLL&DNN&DNN&documentation&documentation&Dotnetnuke&Dotnetnuke&drag+and+drop&drag+and+drop&Dynamic+Languages&Dynamic+Languages&edit&edit&editing&editing&Environement+Variables&Environement+Variables&Frontpage+extensions&Frontpage+extensions&g&g&hosting&hosting&html&html&IIS+7.0&IIS+7.0&IIS+7.0+Frontpage&IIS+7.0+Frontpage&IIS6+compatibility+layer&IIS6+compatibility+layer&iis7&iis7&indexing&indexing&Installation&Installation&intellisense&intellisense&IronRuby&IronRuby&javascript&javascript&layout&layout&LINQ+2+SQL&LINQ+2+SQL&LINQDataSource&LINQDataSource&listview&listview&Mobile+controls&Mobile+controls&MS+Office&MS+Office&MS+Office+2003&MS+Office+2003&msiexec.exe&msiexec.exe&O%2fR+Designer&O%2fR+Designer&Office&Office&Office+2003&Office+2003&Orcas+Express&Orcas+Express&PATH&PATH&PictureBox&PictureBox&proxy&proxy&RAD+Controls&RAD+Controls&remove&remove&Repair&Repair&Reporting+add-in+Web+2008+Express&Reporting+add-in+Web+2008+Express&search&search&Security&Security&shared+hosting&shared+hosting&SilverLight&SilverLight&source+editor&source+editor&sql+2008&sql+2008&sql+server+express+2005&sql+server+express+2005&Starter+kits&Starter+kits&stylesheet&stylesheet&tabpanel&tabpanel&Telerik&Telerik&templates&templates&themes&themes&TookBox&TookBox&Troubleshooting&Troubleshooting&UI&UI&Uninstall&Uninstall&upload&upload&upload+bug&upload+bug&visual+sourcesafe+2005&visual+sourcesafe+2005&Visual+Studio&Visual+Studio&visual+studio+2008&visual+studio+2008&visual+studio+2008+beta&visual+studio+2008+beta&Visual+Web+Developer+2005+Express+Edition&Visual+Web+Developer+2005+Express+Edition&visual+web+developer+2008+express&visual+web+developer+2008+express&Visual+Web+Developer+2008+Express+Edition&Visual+Web+Developer+2008+Express+Edition&Visual+Web+Developer+2008+Express+Edition+-+Installation+Issues&Visual+Web+Developer+2008+Express+Edition+-+Installation+Issues&Visual+Web+Developer+2008+Express+Edition+-+Registration&Visual+Web+Developer+2008+Express+Edition+-+Registration&Visual+Web+Developer+2008+express+Edition+Error+Help&Visual+Web+Developer+2008+express+Edition+Error+Help&visual+web+developer+2008+server+control+design+view+master+page+ajax&visual+web+developer+2008+server+control+design+view+master+page+ajax&vs2008&vs2008&VWD&VWD&VWD+Express&VWD+Express&VWD+Express+2005&VWD+Express+2005&VWD+Express+2008&VWD+Express+2008&VWD+FTP+connexion+publishing&VWD+FTP+connexion+publishing&VWD+WAP+Orcas+Express&VWD+WAP+Orcas+Express&wcf&wcf&web+application+project&web+application+project&Web+Designer+Tools&Web+Designer+Tools&Web+Developer+Multiview+Table&Web+Developer+Multiview+Table&web+Method&web+Method&web+service&web+service&web+service+ajax&web+service+ajax&web+service+ajax+cache&web+service+ajax+cache&web+service+ajax+control+render&web+service+ajax+control+render&web+service+ajax+javascript&web+service+ajax+javascript&web+service+ajax+security&web+service+ajax+security&Web+Service+not+working+on+Server+Farm&Web+Service+not+working+on+Server+Farm&web+servicervice+ajax+databinding&web+servicervice+ajax+databinding&web+services&web+services&web+site&web+site&webmethod++html++json+escaping+repeater&webmethod++html++json+escaping+repeater&webRequest&webRequest&webservice&webservice&WebService+Ajax+DataSet&WebService+Ajax+DataSet&webservice+ajax+firefox&webservice+ajax+firefox&webservice+atlas+activity+indicator&webservice+atlas+activity+indicator&webservice+atlas+profile+security&webservice+atlas+profile+security&Webservice+decimal+separator&Webservice+decimal+separator&webservice+error+handling&webservice+error+handling&webservice+json+ajax&webservice+json+ajax&webservicevice+ajax+permission+error&webservicevice+ajax+permission+error&Windows+2008&Windows+2008&windows+communication+foundation&windows+communication+foundation&Xml&Xml&xml+webservice&xml+webservice&xmlscript&xmlscript&XslDebugProxy&XslDebugProxy></div>Filed
under:
</div>

Did you make any new AntiVirus installation or change the firewall configuration? if yes, then please review it.

Another suggestion is to repair the installation. Go to Add and Remove Program, choose VWDE 2008 and repair the installation.

Hope this helps.

 I’m receiving the same error as above "Cannot locate Microsoft Internet Explorer" using Visual Studio 2008 Professional version 9.0.021022.8 RTM.

I don’t have control over any anti virus software installation or changing the firewall, I have done a repair on the installation. I am still getting the error. I can right click on the .aspx page and view it and every thing works great. It only happens
when I try to view it through the debugger. Any help would be greatly appreciated. thanks

 

 

Visual Studio looks for the following registry key to locate Internet Explorer:

[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionApp Pathsiexplore.exe] 

 

Open regedit and locate this key.

If its not present, then create one with the Default value pointing to your Internet Explorer location. Normally it will be
c:Program FilesInternet Exploreriexplore.exe.

If its already present then check the default value and correct it.

 

To check if its working, open run command, and type in ‘iexplore’ and it should launch the Internet Explorer.

Now try doing a F5 on your Visual Studio and it should work.

 

[RESOLVED]Element 'LinqDataSource' is not a known element … VS 2010 ASP.Net 4.0

I’m getting the below warning error in Visual Studio 2010 when I create a new ASP.Net 4.0 Web Application (WebForms or MVC2).

Element ‘LinqDataSource’ is not a known element…

I open VS, click on "New Project…", select Web / ASP.NET Web Application (.NET Framework 4).

Open the Default.aspx page

Double-click on LinqDataSource in the Toolbox

… and the LinqDataSource is inserted, but it contains no defaulted ID attribute, and there’s the above warning error.

I’ve done some Googling (if that’s a word) and found references to this problem in older (3.5 and prior) framework versions which suggest checking that the following exists in web.config:

<div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">
<pages></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">
<controls></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x:
hidden; overflow-y: hidden;" id="_mcePaste">
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x:
hidden; overflow-y: hidden;" id="_mcePaste">
</controls></div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">
</pages></div> <div></div>

<pages>

<controls>

<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

</controls>

</pages>

<div>
</div><div>I don’t see these in the web.config for an ASP.Net 4.0 project, and from what I’ve read you shouldn’t need these in 4.0.</div><div>
</div><div>Am I doing something wrong?  Does anyone have any suggestions as to how to make the warnings go away?</div><div>
</div><div>Thanks!</div><div>
</div>

LinqDataSource is not a good control to be using for serious apps. I think its still used quite heavily in Dynamic Data but in most cases you should try to use the ObjectDataSource so that you can cleanly separate your concerns.

Lecturing you aside ([:)]) have you tried clicking the Website menu then choosing Add Reference and adding in a reference to System.Data.Linq? Actually not sure if its in that assembly. Its probably somewhere else but not sure where from MSDN docs:

Also are you sure you have targetted 4.0?

My question isn’t regarding the appropriateness of using the LinqDataSource control (Lecture noted), but that the IDE doesn’t seem to fully recognize its existance.

Yes, there is a reference listed for "System.Data.Linq" under the "References" folder.

I also see the same behavior when attempting to add the following controls to a default.aspx page:

  • DataPager
  • EntityDataSource
  • LinqDataSource
  • ListView
  • QueryExtender

Interestingly however, when I add the "Chart" control to the page, it adds the following line at the top of Default.aspx, and all warnings disappear!

<div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"><%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %></div> <div></div>

<%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>

<div>
</div><div>Very odd …</div><div>
</div><div>And yes, I am targeting 4.0.</div>

Might be your schema cache. Can you try the workaround mentioned in
this
post? 

Eureka!  That took care of it!

Thank you Bala!

I simply cleared my schema cache (see below) and my warnings went away…

As a workaround, you can try the following: 

Close VS, delete schema cache, and re-open VS. You can find the schemas under something like:

C:UsersPavelAppDataRoamingMicrosoftVisualStudio10.0ReflectedSchemas

 

It is safe to delete all files in this folder.

Source View and Design View out of Sync – VS 2008 Sp1

Hi Everyone – I’m using VS 2008 Version 9.0.30729. SP1

 I’ve found that frequently, (it seems to happen most frequently when copying and pasting controls) when adding controls to the designer, the source will not update to reflect what is being displayed in the designer. I will even switch to split screen mode
and even though I make changes to either the designer, or the source code… and then sync up… no design changes show up in the source code.

 I will see: <asp:content …> </asp:content>

But in the design view, I have full access to all of the controls in the designer (living inside the content place holder), full access to view their properties, etc… until I close out of the design view. If I open it back up, the controls are now gone
and the blank page shows up again.

 I can "fix" the issue by closing and reopening VS. Any help would be greatly apprciated –

Can you provide more details about repro steps, page structure, controls that you are using, i.e. simplified repro?

I’m using a Master Page and placing content into one of the content placeholders…

From what I’ve found, copying a datagrid / datasource from the source of one page into the source of another will cause this to happen. The grid will draw properly in the design view, and will show as being bound to a datasource… but when I update the
datasource (int this case, a LinqDataSource), the changes will reflect in the designer, but will not carry over to the source.

 Please let me know if you would like me to go into further detail.

 

Thanks -

I’ve found it helps if I do small steps. For  instance in design view, on a gridview, if I add a column and then move its position, it won’t sync. But if I add the column, and switch to source view, then switch back and move the position. it helps

I know this is still kloogy but it helps.

Did anyone find a solution to this problem? It’s happening to me more and more often now (VS 20008 SP1) and now for the first time, quiting the app and restarting hasn’t helped. In fact the out of syncness carried over the relaunch. In design view I changed
a gridview command field into a template field and it didn’t carry over to sourceview. Switch back to design view and it’s a template column. Close VS and restart, load the solution and in design view it’s a template field and in source view still a command
field! Where does it store the mark up it uses to generate the design view if not in the source? 

I am having the same problem. But in my case, it is reversed.

I used master page and wrote the code in Source view, and when I switched to Design view, I found blank page there. I tried the Split view, and it told me,
"Design view is out of sync with Source view. Click here to synchronize views."
I clicked on it, but nothing happened. Then I tried to typed some text in Design view, and even though the text I typed also appeared in Source view, but it was outside the tag <asp:Content …></asp:Content>. Seems that the contentplaceholder was not detected
or whatever you call it, but all the content I put in the contentplaceholder did appear when I run it in browser.

Is this a bug or what?