RE: Update panel with Gridview control
- From: stcheng@xxxxxxxxxxxxxxxxxxxx ("Steven Cheng")
- Date: Fri, 30 Jan 2009 07:39:06 GMT
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:
msdnmg@xxxxxxxxxxxxxx
==================================================
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?= <AlexK@xxxxxxxxxxxxxxxx>
Subject: RE: Update panel with Gridview control
Date: Wed, 28 Jan 2009 12:10:03 -0800
are
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
returned when no orderid# is entered. It looks like the change has has tobe
at this line: and maybe adding & "*" but I am not sure. Any suggestions.found
protected void SqldsOrderDetails_Selecting(object sender,
SqlDataSourceSelectingEventArgs args)
{
args.Command.Parameters.Add(new
System.Data.SqlClient.SqlParameter("@orderid", this.txtOrderID.Text));
}
""Steven Cheng"" wrote:
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
tothat the error occured during the database connection construction, see
callstack below
[ArgumentException: Format of the initialization string does not conform
thatspecification 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
AsyncPostBackTrigger<brpage 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
and/>
</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
Pleasesuggestions about how we can improve the support we provide to you.
madefeel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx
--------------------
From: =?Utf-8?B?QWxleC4gTy4gS29yYW50ZW5n?= <AlexK@xxxxxxxxxxxxxxxx><Ro2wVMeeJHA.8120@xxxxxxxxxxxxxxxxxxxxxx>
References: <00F4F0FF-C57B-4A65-B4E3-8265D732D858@xxxxxxxxxxxxx>
<1D5E27A4-27FB-40E3-A63B-EC4F6962082E@xxxxxxxxxxxxx>
<iNXFZJreJHA.2052@xxxxxxxxxxxxxxxxxxxxxx>
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
Iminor changes to jscript functions and the CustomerNoAjax.aspx page is
working just as expected. However, when I run the Triggers11.aspx page,
errorget
the error below. My goal is make the search button work without hardcoding
the orderid as the author had done. Any suggestions will be admired. Iwill
email you my current working version. Also I am getting this minor
----------------------------------------------------------------------------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.
the----
Format of the initialization string does not conform to specification
starting at index 0.
Description: An unhandled exception occurred during the execution of
initializationcurrent web request. Please review the stack trace for more informationabout
the error and where it originated in the code.
Exception Details: System.ArgumentException: Format of the
currentstring does not conform to specification starting at index 0.
Source Error:
An unhandled exception was generated during the execution of the
web
request. Information regarding the origin and location of the exceptioncan
be identified using the exception stack trace below.
Stack Trace:
""Steven Cheng"" wrote:
Thanks for your reply Alex,
If there is anything unclear, please feel free to let me know.
Hope this helps.
Sincerely,
Steven Cheng
Microsoft
.
- Follow-Ups:
- RE: Update panel with Gridview control
- From: Alex. O. Koranteng
- RE: Update panel with Gridview control
- From: Alex. O. Koranteng
- RE: Update panel with Gridview control
- References:
- Update panel with Gridview control
- From: Alex. O. Koranteng
- RE: Update panel with Gridview control
- From: "Steven Cheng"
- RE: Update panel with Gridview control
- From: Alex. O. Koranteng
- RE: Update panel with Gridview control
- From: "Steven Cheng"
- RE: Update panel with Gridview control
- From: Alex. O. Koranteng
- RE: Update panel with Gridview control
- From: "Steven Cheng"
- RE: Update panel with Gridview control
- From: Alex. O. Koranteng
- Update panel with Gridview control
- Prev by Date: Re: AJAX UpdatePanel & HtmlGenericControl ('div')
- Next by Date: Re: what really is <%# %>, does Eval, Bind needed?
- Previous by thread: RE: Update panel with Gridview control
- Next by thread: RE: Update panel with Gridview control
- Index(es):
Relevant Pages
|