Update panel with Gridview control

A

Alex. O. Koranteng

I am getting the following error mesage from the label control on my aspx
files.

Error creating control:labeid not specified and here is the code below
I have two grids. The first grid shows a gridview with no ajax
functionality. The second grid shows ajax functionality. Any suggestions will
be appreciated. IF you need more info, I will send you a zipped file of the
solution.

<body>
<form id="frm" runat="server" >
<div style="margin-left:35px">
<asp:ScriptManager ID="scriptManager" runat="server" />
<asp:SqlDataSource
ID="sqldsCustomers" runat="server"
SelectCommand="select customerid, companyname, contactname,
contacttitle from dbo.[customers]"
SelectCommandType="Text"
ConnectionString="todo"
CancelSelectOnNullParameter="true" />

<p style="background-color:AliceBlue; width:95%">
Example of two customer GridViews, the top one is not ajax enabled
and sort or paging will cause the entire page to refresh. The bottom
GridView is ajax enabled and does not cause the complete page to rerender<br
/>
</p>
<asp:Label runat="server" Text="Customers - No AJAX"
BackColor="lightblue" Width="95%" />
<asp:GridView id="gvCustomersNoAJAX" runat="server"
DataSourceID="sqldsCustomers" AutoGenerateColumns="true" AllowPaging="true"
AllowSorting="true" PageSize="5" Width="95%">
<AlternatingRowStyle BackColor="aliceBlue" />
<HeaderStyle HorizontalAlign="Left" />
</asp:GridView>
<br />
<asp:UpdatePanel ID="updatePanel" runat="server"
UpdateMode="Conditional">
<ContentTemplate>
<asp:Label runat="server" Text="Customers - With AJAX"
BackColor="lightblue" Width="95%" />
<asp:GridView id="gvCustomersWithAJAX" runat="server"
DataSourceID="sqldsCustomers"
AutoGenerateColumns="true" AllowPaging="true"
AllowSorting="true" PageSize="5" Width="95%">
<AlternatingRowStyle BackColor="aliceBlue" />
<HeaderStyle HorizontalAlign="Left" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<ajaxToolkit:UpdatePanelAnimationExtender ID="upae"
BehaviorID="animation" runat="server" TargetControlID="updatePanel">
<Animations>
<OnUpdating>
<Parallel duration="0">
<ScriptAction Script="onUpdating();" />
</Parallel>
</OnUpdating>
<OnUpdated>
<Parallel duration="0">
<ScriptAction Script="onUpdated();" />
</Parallel>
</OnUpdated>
</Animations>
</ajaxToolkit:UpdatePanelAnimationExtender>
<div id="updateProgressDiv" style="background-color:#CF4342;
display:none; position:absolute;">
<span style="color:#fff; margin:3px">Loading ...</span>
</div>
</div>
</form>
</body>
</html>


Thanks

Alex
 
S

Steven Cheng

Hi Alex,

Regarding on the problem you mentioned, I've performed some test with the
aspx markup you provided. Since you haven't provided script functions(and I
haven't your database), so I modified it to use my own database connection
and scription function. Except these changes, the page can work correctly.
Here is the modified markup I used for test.

You can have a look at my page and compare with yours to see whether there
is anything different. If necessary, I can also send you my test page.

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


<%@ Register Assembly="AjaxControlToolkit"
Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>


<!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 type="text/javascript">

function onUpdating()
{
document.getElementById("divMessage").innerHTML = "onUpdating!";
}

function onUpdated() {
document.getElementById("divMessage").innerHTML = "onUpdated!";
}

</script>
</head>
<body>
<form id="frm" runat="server" >
<div id="divMessage" style="font-size:xx-large">

</div>
<hr />
<div style="margin-left:35px">
<asp:ScriptManager ID="scriptManager" runat="server" />
<asp:SqlDataSource
ID="sqldsCustomers" runat="server"
SelectCommand="SELECT [Name], [Close],
Code:
 FROM [Sheet1]" 
            ConnectionString="<%$ ConnectionStrings:testdbConnectionString 
%>" />    
    
        <p style="background-color:AliceBlue; width:95%">
        Example of two customer GridViews, the top one is not ajax enabled 
and sort or paging will cause the entire page to refresh.  The bottom 
GridView is ajax enabled and does not cause the complete page to 
rerender<br 
/>
        </p>             
        <asp:Label ID="Label1" runat="server" Text="Customers - No AJAX" 
BackColor="lightblue" Width="95%" />            
        <asp:GridView id="gvCustomersNoAJAX" runat="server" 
DataSourceID="sqldsCustomers" AutoGenerateColumns="False" 
AllowPaging="True" 
AllowSorting="True" PageSize="5" Width="95%">
            <AlternatingRowStyle BackColor="aliceBlue" />
            <Columns>
                <asp:BoundField DataField="Name" HeaderText="Name" 
SortExpression="Name" />
                <asp:BoundField DataField="Close" HeaderText="Close" 
SortExpression="Close" />
                <asp:BoundField DataField="Code" HeaderText="Code" 
SortExpression="Code" />
            </Columns>
            <HeaderStyle HorizontalAlign="Left" />
        </asp:GridView>
        <br />
        <asp:UpdatePanel ID="updatePanel" runat="server" 
UpdateMode="Conditional">
            <ContentTemplate>            
                <asp:Label ID="Label2" runat="server" Text="Customers - 
With AJAX" 
BackColor="lightblue" Width="95%" />            
                <asp:GridView id="gvCustomersWithAJAX" runat="server" 
DataSourceID="sqldsCustomers" 
                    AutoGenerateColumns="False" AllowPaging="True" 
AllowSorting="True" PageSize="5" Width="95%">
                    <AlternatingRowStyle BackColor="aliceBlue" />
                    <Columns>
                        <asp:BoundField DataField="Name" HeaderText="Name" 
SortExpression="Name" />
                        <asp:BoundField DataField="Close" 
HeaderText="Close" SortExpression="Close" />
                        <asp:BoundField DataField="Code" HeaderText="Code" 
SortExpression="Code" />
                    </Columns>
                    <HeaderStyle HorizontalAlign="Left" />
                </asp:GridView>
            </ContentTemplate>
        </asp:UpdatePanel>            
       
       
                 <ajaxToolkit:UpdatePanelAnimationExtender ID="upae" 
BehaviorID="animation" runat="server" TargetControlID="updatePanel">
            <Animations>
                <OnUpdating>
                  
                    <Parallel duration="0">
                        <ScriptAction Script="onUpdating();" />  
                     </Parallel>
                </OnUpdating>
                <OnUpdated>
                    <Parallel duration="0">
                        <ScriptAction Script="onUpdated();" /> 
                    </Parallel>  
                </OnUpdated>
            </Animations>
        </ajaxToolkit:UpdatePanelAnimationExtender>  
       

       
        <div id="updateProgressDiv" style="background-color:#CF4342; 
display:none; position:absolute;">
            <span style="color:#fff; margin:3px">Loading ...</span>
        </div>                               
    </div>
    </form>
</body>

</html>
==========================================

If there is anything need help, please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and 
suggestions about how we can improve the support we provide to you. Please 
feel free to let my manager know what you think of the level of service 
provided. You can send feedback directly to my manager at: 
[email protected].

==================================================
Get notification to my posts through email? Please refer to 
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

--------------------
 
A

Alex. O. Koranteng

Steve,

Thanks for the response. I'll play with your code and update you of my
progress by Wednesday. I have always enjoyed your support.

"Steven Cheng" said:
Hi Alex,

Regarding on the problem you mentioned, I've performed some test with the
aspx markup you provided. Since you haven't provided script functions(and I
haven't your database), so I modified it to use my own database connection
and scription function. Except these changes, the page can work correctly.
Here is the modified markup I used for test.

You can have a look at my page and compare with yours to see whether there
is anything different. If necessary, I can also send you my test page.

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


<%@ Register Assembly="AjaxControlToolkit"
Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>


<!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 type="text/javascript">

function onUpdating()
{
document.getElementById("divMessage").innerHTML = "onUpdating!";
}

function onUpdated() {
document.getElementById("divMessage").innerHTML = "onUpdated!";
}

</script>
</head>
<body>
<form id="frm" runat="server" >
<div id="divMessage" style="font-size:xx-large">

</div>
<hr />
<div style="margin-left:35px">
<asp:ScriptManager ID="scriptManager" runat="server" />
<asp:SqlDataSource
ID="sqldsCustomers" runat="server"
SelectCommand="SELECT [Name], [Close],
Code:
 FROM [Sheet1]" 
ConnectionString="<%$ ConnectionStrings:testdbConnectionString 
%>" />    

<p style="background-color:AliceBlue; width:95%">
Example of two customer GridViews, the top one is not ajax enabled 
and sort or paging will cause the entire page to refresh.  The bottom 
GridView is ajax enabled and does not cause the complete page to 
rerender<br 
/>
</p>             
<asp:Label ID="Label1" runat="server" Text="Customers - No AJAX" 
BackColor="lightblue" Width="95%" />            
<asp:GridView id="gvCustomersNoAJAX" runat="server" 
DataSourceID="sqldsCustomers" AutoGenerateColumns="False" 
AllowPaging="True" 
AllowSorting="True" PageSize="5" Width="95%">
<AlternatingRowStyle BackColor="aliceBlue" />
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name" 
SortExpression="Name" />
<asp:BoundField DataField="Close" HeaderText="Close" 
SortExpression="Close" />
<asp:BoundField DataField="Code" HeaderText="Code" 
SortExpression="Code" />
</Columns>
<HeaderStyle HorizontalAlign="Left" />
</asp:GridView>
<br />
<asp:UpdatePanel ID="updatePanel" runat="server" 
UpdateMode="Conditional">
<ContentTemplate>            
<asp:Label ID="Label2" runat="server" Text="Customers - 
With AJAX" 
BackColor="lightblue" Width="95%" />            
<asp:GridView id="gvCustomersWithAJAX" runat="server" 
DataSourceID="sqldsCustomers" 
AutoGenerateColumns="False" AllowPaging="True" 
AllowSorting="True" PageSize="5" Width="95%">
<AlternatingRowStyle BackColor="aliceBlue" />
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name" 
SortExpression="Name" />
<asp:BoundField DataField="Close" 
HeaderText="Close" SortExpression="Close" />
<asp:BoundField DataField="Code" HeaderText="Code" 
SortExpression="Code" />
</Columns>
<HeaderStyle HorizontalAlign="Left" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>            


<ajaxToolkit:UpdatePanelAnimationExtender ID="upae" 
BehaviorID="animation" runat="server" TargetControlID="updatePanel">
<Animations>
<OnUpdating>

<Parallel duration="0">
<ScriptAction Script="onUpdating();" />  
</Parallel>
</OnUpdating>
<OnUpdated>
<Parallel duration="0">
<ScriptAction Script="onUpdated();" /> 
</Parallel>  
</OnUpdated>
</Animations>
</ajaxToolkit:UpdatePanelAnimationExtender>  



<div id="updateProgressDiv" style="background-color:#CF4342; 
display:none; position:absolute;">
<span style="color:#fff; margin:3px">Loading ...</span>
</div>                               
</div>
</form>
</body>

</html>
==========================================

If there is anything need help, please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and 
suggestions about how we can improve the support we provide to you. Please 
feel free to let my manager know what you think of the level of service 
provided. You can send feedback directly to my manager at: 
[email protected].

==================================================
Get notification to my posts through email? Please refer to 
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

--------------------[QUOTE]
From: =?Utf-8?B?QWxleC4gTy4gS29yYW50ZW5n?= <[email protected]>
Subject: Update panel with Gridview control
Date: Fri, 16 Jan 2009 11:27:01 -0800[/QUOTE]
[QUOTE]
I am getting the following error mesage from the label control on my aspx 
files.

Error creating control:labeid not specified and here is the code below
I have two grids. The first grid shows a gridview with no ajax 
functionality. The second grid shows ajax functionality. Any suggestions  will 
be appreciated. IF you need more info, I will send you a zipped file of  the 
solution.

<body>
<form id="frm" runat="server" >   
<>        [/QUOTE]
[/QUOTE]
 
A

Alex. O. Koranteng

Steve,

Thanks for all your code suggestions. I have added your code and just made
minor changes to jscript functions and the CustomerNoAjax.aspx page is
working just as expected. However, when I run the Triggers11.aspx page, I get
the error below. My goal is make the search button work without hard coding
the orderid as the author had done. Any suggestions will be admired. I will
email you my current working version. Also I am getting this minor error
label:ID property is not specified which I do not see why because in my
solution, I ahve defined the id property
Thanks

Server Error in '/in_depth_update_panel1' Application.
--------------------------------------------------------------------------------

Format of the initialization string does not conform to specification
starting at index 0.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.ArgumentException: Format of the initialization
string does not conform to specification starting at index 0.

Source Error:

An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.

Stack Trace:
 
S

Steven Cheng

Hi Alex,

I've checked the project you sent me. Yes, I got the error when tried
running "trigger1.aspx". Based on the error message and callstack, I found
that the error occured during the database connection construction, see
callstack below

[ArgumentException: Format of the initialization string does not conform to
specification starting at index 0.]
System.Data.Common.DbConnectionOptions.GetKeyValuePair(String
connectionString, Int32 currentPosition, StringBuilder buffer, Boolean
useOdbcRules, String& keyname, String& keyvalue) +1242
System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable
parsetable, String connectionString, Boolean buildChain, Hashtable
synonyms, Boolean firstKey) +126
System.Data.Common.DbConnectionOptions..ctor(String connectionString,
Hashtable synonyms, Boolean useOdbcRules) +102
<<<<<<<<<<<<<<<<

So I checked the connectionString of the SqlDataSource control used on that
page and found that you haven't specified the correct connectionString
expression. Here is the original content:

======================
<asp:SqlDataSource
ID="sqldsOrderDetails" runat="server"
SelectCommand="select * from dbo.[order details] where
orderid=@orderid"
SelectCommandType="Text"
ConnectionString="todo"
OnSelecting="SqldsOrderDetails_Selecting"
CancelSelectOnNullParameter="true" />

<p style="background-color:AliceBlue; width:95%">
Example linking the UpdatePanel to a button outside of the panel
that triggers the asynchronous post-back using the AsyncPostBackTrigger<br
/>
</p>
===================

You need to change the connectionString to the correct one(pointing to
NorthWind database), like below:
==========================

<asp:SqlDataSource
ID="sqldsOrderDetails" runat="server"
SelectCommand="select * from dbo.[order details] where
orderid=@orderid"
SelectCommandType="Text"
ConnectionString="<%$
ConnectionStrings:NorthwindConnectionString %>"
OnSelecting="SqldsOrderDetails_Selecting"
CancelSelectOnNullParameter="true" />

<p style="background-color:AliceBlue; width:95%">
Example linking the UpdatePanel to a button outside of the panel
that triggers the asynchronous post-back using the AsyncPostBackTrigger<br
/>
</p>
=============================

Then, the page starts working.

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).


--------------------
From: =?Utf-8?B?QWxleC4gTy4gS29yYW50ZW5n?= <[email protected]>
References: <[email protected]>
<[email protected]>
 
A

Alex. O. Koranteng

Steve,

I have implemented your code changes and the search button is working for
orderid# entered. However, How do I tweak my code such that all records are
returned when no orderid# is entered. It looks like the change has has to be
at this line: and maybe adding & "*" but I am not sure. Any suggestions.


protected void SqldsOrderDetails_Selecting(object sender,
SqlDataSourceSelectingEventArgs args)
{
args.Command.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@orderid", this.txtOrderID.Text));
}

"Steven Cheng" said:
Hi Alex,

I've checked the project you sent me. Yes, I got the error when tried
running "trigger1.aspx". Based on the error message and callstack, I found
that the error occured during the database connection construction, see
callstack below

[ArgumentException: Format of the initialization string does not conform to
specification starting at index 0.]
System.Data.Common.DbConnectionOptions.GetKeyValuePair(String
connectionString, Int32 currentPosition, StringBuilder buffer, Boolean
useOdbcRules, String& keyname, String& keyvalue) +1242
System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable
parsetable, String connectionString, Boolean buildChain, Hashtable
synonyms, Boolean firstKey) +126
System.Data.Common.DbConnectionOptions..ctor(String connectionString,
Hashtable synonyms, Boolean useOdbcRules) +102
<<<<<<<<<<<<<<<<

So I checked the connectionString of the SqlDataSource control used on that
page and found that you haven't specified the correct connectionString
expression. Here is the original content:

======================
<asp:SqlDataSource
ID="sqldsOrderDetails" runat="server"
SelectCommand="select * from dbo.[order details] where
orderid=@orderid"
SelectCommandType="Text"
ConnectionString="todo"
OnSelecting="SqldsOrderDetails_Selecting"
CancelSelectOnNullParameter="true" />

<p style="background-color:AliceBlue; width:95%">
Example linking the UpdatePanel to a button outside of the panel
that triggers the asynchronous post-back using the AsyncPostBackTrigger<br
/>
</p>
===================

You need to change the connectionString to the correct one(pointing to
NorthWind database), like below:
==========================

<asp:SqlDataSource
ID="sqldsOrderDetails" runat="server"
SelectCommand="select * from dbo.[order details] where
orderid=@orderid"
SelectCommandType="Text"
ConnectionString="<%$
ConnectionStrings:NorthwindConnectionString %>"
OnSelecting="SqldsOrderDetails_Selecting"
CancelSelectOnNullParameter="true" />

<p style="background-color:AliceBlue; width:95%">
Example linking the UpdatePanel to a button outside of the panel
that triggers the asynchronous post-back using the AsyncPostBackTrigger<br
/>
</p>
=============================

Then, the page starts working.

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).


--------------------
From: =?Utf-8?B?QWxleC4gTy4gS29yYW50ZW5n?= <[email protected]>
References: <[email protected]>
<[email protected]>
Subject: RE: Update panel with Gridview control
Date: Sat, 24 Jan 2009 16:21:01 -0800
Steve,

Thanks for all your code suggestions. I have added your code and just made
minor changes to jscript functions and the CustomerNoAjax.aspx page is
working just as expected. However, when I run the Triggers11.aspx page, I get
the error below. My goal is make the search button work without hard coding
the orderid as the author had done. Any suggestions will be admired. I will
email you my current working version. Also I am getting this minor error
label:ID property is not specified which I do not see why because in my
solution, I ahve defined the id property
Thanks

Server Error in '/in_depth_update_panel1' Application. ----------------------------------------------------------------------------
----

Format of the initialization string does not conform to specification
starting at index 0.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.ArgumentException: Format of the initialization
string does not conform to specification starting at index 0.

Source Error:

An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.

Stack Trace:
 
S

Steven Cheng

Thanks for your followup Alex,

Glad to hear that you've got further progress on this.

Regarding on your new questions(deal with empty input parameter of the
TextBox), there are two ideas come up to my mind:

1. You can put the GridView into a panel ,and another GridView(within a
separate panel) on the page. And you can make either one of them visible
depend on the Value in TextBox(whether it is empty or not). And one of the
GridView will alway manually query all the records from table. Also, to
improve performance, you can only perform databinding manually(for that
gridview which display all records) when the TextBox is empty.


2. change the SQL select statement of the SqlDAtaSource control you used.
Add an additinal parameter to control whether it will return all the
records or not:

e.g.

=============================
<asp:SqlDataSource
ID="sqldsOrderDetails" runat="server"
SelectCommand="select * from dbo.[order details] where
orderid=@orderid OR 1 = @display_all"

.................... />



protected void SqldsOrderDetails_Selecting(object sender,
SqlDataSourceSelectingEventArgs args)
{
args.Command.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@orderid", this.txtOrderID.Text));

System.Data.SqlClient.SqlParameter parameter = new
System.Data.SqlClient.SqlParameter("@display_all",
System.Data.SqlDbType.Bit);
if (string.IsNullOrEmpty(txtOrderID.Text.Trim()))
{
parameter.Value = 1;
}
else
{
parameter.Value = 0;
}

args.Command.Parameters.Add(parameter);
}
==============================

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

--------------------
From: =?Utf-8?B?QWxleC4gTy4gS29yYW50ZW5n?= <[email protected]>
Subject: RE: Update panel with Gridview control
Date: Wed, 28 Jan 2009 12:10:03 -0800
Steve,

I have implemented your code changes and the search button is working for
orderid# entered. However, How do I tweak my code such that all records are
returned when no orderid# is entered. It looks like the change has has to be
at this line: and maybe adding & "*" but I am not sure. Any suggestions.


protected void SqldsOrderDetails_Selecting(object sender,
SqlDataSourceSelectingEventArgs args)
{
args.Command.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@orderid", this.txtOrderID.Text));
}

"Steven Cheng" said:
Hi Alex,

I've checked the project you sent me. Yes, I got the error when tried
running "trigger1.aspx". Based on the error message and callstack, I found
that the error occured during the database connection construction, see
callstack below

[ArgumentException: Format of the initialization string does not conform to
specification starting at index 0.]
System.Data.Common.DbConnectionOptions.GetKeyValuePair(String
connectionString, Int32 currentPosition, StringBuilder buffer, Boolean
useOdbcRules, String& keyname, String& keyvalue) +1242
System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable
parsetable, String connectionString, Boolean buildChain, Hashtable
synonyms, Boolean firstKey) +126
System.Data.Common.DbConnectionOptions..ctor(String connectionString,
Hashtable synonyms, Boolean useOdbcRules) +102
<<<<<<<<<<<<<<<<

So I checked the connectionString of the SqlDataSource control used on that
page and found that you haven't specified the correct connectionString
expression. Here is the original content:

======================
<asp:SqlDataSource
ID="sqldsOrderDetails" runat="server"
SelectCommand="select * from dbo.[order details] where
orderid=@orderid"
SelectCommandType="Text"
ConnectionString="todo"
OnSelecting="SqldsOrderDetails_Selecting"
CancelSelectOnNullParameter="true" />

<p style="background-color:AliceBlue; width:95%">
Example linking the UpdatePanel to a button outside of the panel
that triggers the asynchronous post-back using the AsyncPostBackTrigger<br
/>
</p>
===================

You need to change the connectionString to the correct one(pointing to
NorthWind database), like below:
==========================

<asp:SqlDataSource
ID="sqldsOrderDetails" runat="server"
SelectCommand="select * from dbo.[order details] where
orderid=@orderid"
SelectCommandType="Text"
ConnectionString="<%$
ConnectionStrings:NorthwindConnectionString %>"
OnSelecting="SqldsOrderDetails_Selecting"
CancelSelectOnNullParameter="true" />

<p style="background-color:AliceBlue; width:95%">
Example linking the UpdatePanel to a button outside of the panel
that triggers the asynchronous post-back using the AsyncPostBackTrigger<br
/>
</p>
=============================

Then, the page starts working.

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).


--------------------
From: =?Utf-8?B?QWxleC4gTy4gS29yYW50ZW5n?= <[email protected]>
References: <[email protected]>
<[email protected]>
Subject: RE: Update panel with Gridview control
Date: Sat, 24 Jan 2009 16:21:01 -0800
Steve,

Thanks for all your code suggestions. I have added your code and just made
minor changes to jscript functions and the CustomerNoAjax.aspx page is
working just as expected. However, when I run the Triggers11.aspx page,
I
get
the error below. My goal is make the search button work without hard coding
the orderid as the author had done. Any suggestions will be admired. I will
email you my current working version. Also I am getting this minor error
label:ID property is not specified which I do not see why because in my
solution, I ahve defined the id property
Thanks

Server Error in '/in_depth_update_panel1' Application.
----------------------------------------------------------------------------
----
Format of the initialization string does not conform to specification
starting at index 0.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.ArgumentException: Format of the initialization
string does not conform to specification starting at index 0.

Source Error:

An unhandled exception was generated during the execution of the
current
web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.

Stack Trace:

:

Thanks for your reply Alex,

If there is anything unclear, please feel free to let me know.

Hope this helps.

Sincerely,

Steven Cheng

Microsoft
 
A

Alex. O. Koranteng

Steve,

Thanks for the response. I will implement your code suggstions and update
you by Monday. I appreciate all your support.

"Steven Cheng" said:
Thanks for your followup Alex,

Glad to hear that you've got further progress on this.

Regarding on your new questions(deal with empty input parameter of the
TextBox), there are two ideas come up to my mind:

1. You can put the GridView into a panel ,and another GridView(within a
separate panel) on the page. And you can make either one of them visible
depend on the Value in TextBox(whether it is empty or not). And one of the
GridView will alway manually query all the records from table. Also, to
improve performance, you can only perform databinding manually(for that
gridview which display all records) when the TextBox is empty.


2. change the SQL select statement of the SqlDAtaSource control you used.
Add an additinal parameter to control whether it will return all the
records or not:

e.g.

=============================
<asp:SqlDataSource
ID="sqldsOrderDetails" runat="server"
SelectCommand="select * from dbo.[order details] where
orderid=@orderid OR 1 = @display_all"

.................... />



protected void SqldsOrderDetails_Selecting(object sender,
SqlDataSourceSelectingEventArgs args)
{
args.Command.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@orderid", this.txtOrderID.Text));

System.Data.SqlClient.SqlParameter parameter = new
System.Data.SqlClient.SqlParameter("@display_all",
System.Data.SqlDbType.Bit);
if (string.IsNullOrEmpty(txtOrderID.Text.Trim()))
{
parameter.Value = 1;
}
else
{
parameter.Value = 0;
}

args.Command.Parameters.Add(parameter);
}
==============================

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

--------------------
From: =?Utf-8?B?QWxleC4gTy4gS29yYW50ZW5n?= <[email protected]>
Subject: RE: Update panel with Gridview control
Date: Wed, 28 Jan 2009 12:10:03 -0800
Steve,

I have implemented your code changes and the search button is working for
orderid# entered. However, How do I tweak my code such that all records are
returned when no orderid# is entered. It looks like the change has has to be
at this line: and maybe adding & "*" but I am not sure. Any suggestions.


protected void SqldsOrderDetails_Selecting(object sender,
SqlDataSourceSelectingEventArgs args)
{
args.Command.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@orderid", this.txtOrderID.Text));
}

"Steven Cheng" said:
Hi Alex,

I've checked the project you sent me. Yes, I got the error when tried
running "trigger1.aspx". Based on the error message and callstack, I found
that the error occured during the database connection construction, see
callstack below



[ArgumentException: Format of the initialization string does not conform to
specification starting at index 0.]
System.Data.Common.DbConnectionOptions.GetKeyValuePair(String
connectionString, Int32 currentPosition, StringBuilder buffer, Boolean
useOdbcRules, String& keyname, String& keyvalue) +1242
System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable
parsetable, String connectionString, Boolean buildChain, Hashtable
synonyms, Boolean firstKey) +126
System.Data.Common.DbConnectionOptions..ctor(String connectionString,
Hashtable synonyms, Boolean useOdbcRules) +102
<<<<<<<<<<<<<<<<

So I checked the connectionString of the SqlDataSource control used on that
page and found that you haven't specified the correct connectionString
expression. Here is the original content:

======================
<asp:SqlDataSource
ID="sqldsOrderDetails" runat="server"
SelectCommand="select * from dbo.[order details] where
orderid=@orderid"
SelectCommandType="Text"
ConnectionString="todo"
OnSelecting="SqldsOrderDetails_Selecting"
CancelSelectOnNullParameter="true" />

<p style="background-color:AliceBlue; width:95%">
Example linking the UpdatePanel to a button outside of the panel
that triggers the asynchronous post-back using the AsyncPostBackTrigger<br
/>
</p>
===================

You need to change the connectionString to the correct one(pointing to
NorthWind database), like below:
==========================

<asp:SqlDataSource
ID="sqldsOrderDetails" runat="server"
SelectCommand="select * from dbo.[order details] where
orderid=@orderid"
SelectCommandType="Text"
ConnectionString="<%$
ConnectionStrings:NorthwindConnectionString %>"
OnSelecting="SqldsOrderDetails_Selecting"
CancelSelectOnNullParameter="true" />

<p style="background-color:AliceBlue; width:95%">
Example linking the UpdatePanel to a button outside of the panel
that triggers the asynchronous post-back using the AsyncPostBackTrigger<br
/>
</p>
=============================

Then, the page starts working.

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).


--------------------
From: =?Utf-8?B?QWxleC4gTy4gS29yYW50ZW5n?= <[email protected]>
References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
Subject: RE: Update panel with Gridview control
Date: Sat, 24 Jan 2009 16:21:01 -0800


Steve,

Thanks for all your code suggestions. I have added your code and just made
minor changes to jscript functions and the CustomerNoAjax.aspx page is
working just as expected. However, when I run the Triggers11.aspx page, I
get
the error below. My goal is make the search button work without hard
coding
the orderid as the author had done. Any suggestions will be admired. I
will
email you my current working version. Also I am getting this minor error
label:ID property is not specified which I do not see why because in my
solution, I ahve defined the id property
Thanks

Server Error in '/in_depth_update_panel1' Application.
----------------------------------------------------------------------------
----

Format of the initialization string does not conform to specification
starting at index 0.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about
the error and where it originated in the code.

Exception Details: System.ArgumentException: Format of the initialization
string does not conform to specification starting at index 0.

Source Error:

An unhandled exception was generated during the execution of the current
web
request. Information regarding the origin and location of the exception
can
be identified using the exception stack trace below.

Stack Trace:

:

Thanks for your reply Alex,

If there is anything unclear, please feel free to let me know.

Hope this helps.

Sincerely,

Steven Cheng

Microsoft
 
A

Alex. O. Koranteng

Steve,

Thanks for your response. I will implement your code changes and update you
by Monday. I really appreciate your support immensely.

Alex

"Steven Cheng" said:
Thanks for your followup Alex,

Glad to hear that you've got further progress on this.

Regarding on your new questions(deal with empty input parameter of the
TextBox), there are two ideas come up to my mind:

1. You can put the GridView into a panel ,and another GridView(within a
separate panel) on the page. And you can make either one of them visible
depend on the Value in TextBox(whether it is empty or not). And one of the
GridView will alway manually query all the records from table. Also, to
improve performance, you can only perform databinding manually(for that
gridview which display all records) when the TextBox is empty.


2. change the SQL select statement of the SqlDAtaSource control you used.
Add an additinal parameter to control whether it will return all the
records or not:

e.g.

=============================
<asp:SqlDataSource
ID="sqldsOrderDetails" runat="server"
SelectCommand="select * from dbo.[order details] where
orderid=@orderid OR 1 = @display_all"

.................... />



protected void SqldsOrderDetails_Selecting(object sender,
SqlDataSourceSelectingEventArgs args)
{
args.Command.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@orderid", this.txtOrderID.Text));

System.Data.SqlClient.SqlParameter parameter = new
System.Data.SqlClient.SqlParameter("@display_all",
System.Data.SqlDbType.Bit);
if (string.IsNullOrEmpty(txtOrderID.Text.Trim()))
{
parameter.Value = 1;
}
else
{
parameter.Value = 0;
}

args.Command.Parameters.Add(parameter);
}
==============================

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

--------------------
From: =?Utf-8?B?QWxleC4gTy4gS29yYW50ZW5n?= <[email protected]>
Subject: RE: Update panel with Gridview control
Date: Wed, 28 Jan 2009 12:10:03 -0800
Steve,

I have implemented your code changes and the search button is working for
orderid# entered. However, How do I tweak my code such that all records are
returned when no orderid# is entered. It looks like the change has has to be
at this line: and maybe adding & "*" but I am not sure. Any suggestions.


protected void SqldsOrderDetails_Selecting(object sender,
SqlDataSourceSelectingEventArgs args)
{
args.Command.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@orderid", this.txtOrderID.Text));
}

"Steven Cheng" said:
Hi Alex,

I've checked the project you sent me. Yes, I got the error when tried
running "trigger1.aspx". Based on the error message and callstack, I found
that the error occured during the database connection construction, see
callstack below



[ArgumentException: Format of the initialization string does not conform to
specification starting at index 0.]
System.Data.Common.DbConnectionOptions.GetKeyValuePair(String
connectionString, Int32 currentPosition, StringBuilder buffer, Boolean
useOdbcRules, String& keyname, String& keyvalue) +1242
System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable
parsetable, String connectionString, Boolean buildChain, Hashtable
synonyms, Boolean firstKey) +126
System.Data.Common.DbConnectionOptions..ctor(String connectionString,
Hashtable synonyms, Boolean useOdbcRules) +102
<<<<<<<<<<<<<<<<

So I checked the connectionString of the SqlDataSource control used on that
page and found that you haven't specified the correct connectionString
expression. Here is the original content:

======================
<asp:SqlDataSource
ID="sqldsOrderDetails" runat="server"
SelectCommand="select * from dbo.[order details] where
orderid=@orderid"
SelectCommandType="Text"
ConnectionString="todo"
OnSelecting="SqldsOrderDetails_Selecting"
CancelSelectOnNullParameter="true" />

<p style="background-color:AliceBlue; width:95%">
Example linking the UpdatePanel to a button outside of the panel
that triggers the asynchronous post-back using the AsyncPostBackTrigger<br
/>
</p>
===================

You need to change the connectionString to the correct one(pointing to
NorthWind database), like below:
==========================

<asp:SqlDataSource
ID="sqldsOrderDetails" runat="server"
SelectCommand="select * from dbo.[order details] where
orderid=@orderid"
SelectCommandType="Text"
ConnectionString="<%$
ConnectionStrings:NorthwindConnectionString %>"
OnSelecting="SqldsOrderDetails_Selecting"
CancelSelectOnNullParameter="true" />

<p style="background-color:AliceBlue; width:95%">
Example linking the UpdatePanel to a button outside of the panel
that triggers the asynchronous post-back using the AsyncPostBackTrigger<br
/>
</p>
=============================

Then, the page starts working.

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).


--------------------
From: =?Utf-8?B?QWxleC4gTy4gS29yYW50ZW5n?= <[email protected]>
References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
Subject: RE: Update panel with Gridview control
Date: Sat, 24 Jan 2009 16:21:01 -0800


Steve,

Thanks for all your code suggestions. I have added your code and just made
minor changes to jscript functions and the CustomerNoAjax.aspx page is
working just as expected. However, when I run the Triggers11.aspx page, I
get
the error below. My goal is make the search button work without hard
coding
the orderid as the author had done. Any suggestions will be admired. I
will
email you my current working version. Also I am getting this minor error
label:ID property is not specified which I do not see why because in my
solution, I ahve defined the id property
Thanks

Server Error in '/in_depth_update_panel1' Application.
----------------------------------------------------------------------------
----

Format of the initialization string does not conform to specification
starting at index 0.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about
the error and where it originated in the code.

Exception Details: System.ArgumentException: Format of the initialization
string does not conform to specification starting at index 0.

Source Error:

An unhandled exception was generated during the execution of the current
web
request. Information regarding the origin and location of the exception
can
be identified using the exception stack trace below.

Stack Trace:

:

Thanks for your reply Alex,

If there is anything unclear, please feel free to let me know.

Hope this helps.

Sincerely,

Steven Cheng

Microsoft
 
S

Steven Cheng

Thanks for your reply Alex,

I'm glad to assist. BTW, if convenient, I suggest you start a new thread
next time so as to cut the current long thread. That'll make the thread
looks more clearly.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

--------------------
From: =?Utf-8?B?QWxleC4gTy4gS29yYW50ZW5n?= <[email protected]>
Subject: RE: Update panel with Gridview control
Date: Fri, 30 Jan 2009 07:59:02 -0800
Steve,

Thanks for your response. I will implement your code changes and update you
by Monday. I really appreciate your support immensely.

Alex

"Steven Cheng" said:
Thanks for your followup Alex,

Glad to hear that you've got further progress on this.

Regarding on your new questions(deal with empty input parameter of the
TextBox), there are two ideas come up to my mind:

1. You can put the GridView into a panel ,and another GridView(within a
separate panel) on the page. And you can make either one of them visible
depend on the Value in TextBox(whether it is empty or not). And one of the
GridView will alway manually query all the records from table. Also, to
improve performance, you can only perform databinding manually(for that
gridview which display all records) when the TextBox is empty.


2. change the SQL select statement of the SqlDAtaSource control you used.
Add an additinal parameter to control whether it will return all the
records or not:

e.g.

=============================
<asp:SqlDataSource
ID="sqldsOrderDetails" runat="server"
SelectCommand="select * from dbo.[order details] where
orderid=@orderid OR 1 = @display_all"

.................... />



protected void SqldsOrderDetails_Selecting(object sender,
SqlDataSourceSelectingEventArgs args)
{
args.Command.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@orderid", this.txtOrderID.Text));

System.Data.SqlClient.SqlParameter parameter = new
System.Data.SqlClient.SqlParameter("@display_all",
System.Data.SqlDbType.Bit);
if (string.IsNullOrEmpty(txtOrderID.Text.Trim()))
{
parameter.Value = 1;
}
else
{
parameter.Value = 0;
}

args.Command.Parameters.Add(parameter);
}
==============================

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,052
Latest member
LucyCarper

Latest Threads

Top