Why isn't my SelectCountMethod getting called? - asp.net

I'm binding a GridView to a ObjectDataSource.
I'm expecting the m_ObjectDataSourceGrid_Selected method to fire twice, once for the Select and again for the Count, but it only fires once.
What's going on?
<asp:GridView ID="m_GridViewDocClasses" runat="server" AutoGenerateColumns="False"
DataSourceID="m_ObjectDataSourceGrid"
AllowSorting="true">
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="DocClass.aspx?DocClassId={0}"
Text="Edit" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
</Columns>
</asp:GridView>
</div>
<asp:ObjectDataSource ID="m_ObjectDataSourceGrid" runat="server" SelectMethod="GetDocClasses"
TypeName="SouthernCompany.Generation.SPORT.Business.DocClassBL" OnObjectCreating="m_ObjectDataSourceGrid_ObjectCreating"
OnSelected="m_ObjectDataSourceGrid_Selected" SelectCountMethod="GetDocClassesCount"
SortParameterName="sort">
<SelectParameters>
<asp:Parameter DefaultValue="" Name="sort" Type="String" />
<asp:Parameter DefaultValue="0" Name="startRowIndex" Type="Int32" />
<asp:Parameter DefaultValue="0" Name="maximumRows" Type="Int32" />
<asp:Parameter DefaultValue="0" Name="docClassId" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>

You can not because you haven't assigned allowpaging, put these three:
AllowPaging="true"
AllowSorting="true"
PageSize="25"
AllowPaging is needed to call the SelectCountMethod.
remove allowsorting if not needed.

Does your SelectCountMethod is receiving the same parameters as SelectMethod? There's two ways that makes SelectCountMethod acceptable: without any parameter "()" or with the same parameters as SelectMethod, besides Sorting and Paging parameters.

Related

incorrect syntax near nvarchar in gridview

I have a problem about the updating a column of my gridview; when I try to update the field I get this error:
Incorrect syntax near 'nvarchar'.
Must declare the scalar variable "#pid".
Here is a piece of my code:
<asp:GridView ID="GridView1" runat="server" name="gd" Height="100px"
Width="435px" AutoGenerateColumns="False" DataKeyNames="pid" DataSourceID="SqlDataSource1" >
<Columns>
<asp:CommandField ShowEditButton="True" ShowSelectButton="True" />
<asp:BoundField DataField="pid" HeaderText="pid"
SortExpression="pid" ReadOnly="True" />
<asp:BoundField DataField="name" HeaderText="name"
SortExpression="name" />
<asp:BoundField DataField="hoghoghe rozane" HeaderText="hoghoghe rozane"
SortExpression="hoghoghe rozane" />
<asp:BoundField DataField="paye" HeaderText="paye"
SortExpression="paye" />
<\Columns>
<asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
UpdateCommand="UPDATE [post] SET [name] = #name, hoghoghe_rozane = #hoghoghe_rozane, [paye] = #paye WHERE (pid = #pid)" >
<UpdateParameters>
<asp:Parameter Name="name" Type="String" />
<asp:Parameter Name="hoghoghe_rozane" Type="Int32" />
<asp:Parameter Name="paye" Type="Int32" />
<asp:Parameter Name="pid" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
chek this out : same problem
it says you must change [hoghoghe rozane] into [hoghoghe_rozane]
Update :::
1.Make sure that the type of pid field in database
2.fields should not have spaces in your tables
3.alias should not have spaces too
try this code :
<asp:GridView ID="GridView1" runat="server" name="gd" Height="100px"
Width="435px" AutoGenerateColumns="False" DataKeyNames="pid" DataSourceID="SqlDataSource1" >
<Columns>
<asp:CommandField ShowEditButton="True" ShowSelectButton="True" />
<asp:BoundField DataField="pid" HeaderText="pid"
SortExpression="pid" ReadOnly="True" />
<asp:BoundField DataField="name" HeaderText="name"
SortExpression="name" />
<asp:BoundField DataField="hoghoghe_rozane" HeaderText="hoghogheRozane"
SortExpression="hoghoghe_rozane" />
<asp:BoundField DataField="paye" HeaderText="paye"
SortExpression="paye" />
<\Columns>
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
UpdateCommand="UPDATE [post] SET [name] = #name, hoghoghe_rozane = #hoghoghe_rozane, [paye] = #paye WHERE (pid = #pid)" >
<UpdateParameters>
<asp:Parameter Name="name" Type="String" />
<asp:Parameter Name="hoghoghe_rozane" Type="Int32" />
<asp:Parameter Name="paye" Type="Int32" />
<asp:Parameter Name="pid" Type="String" />
</UpdateParameters>
hope that would work.

Can you please tell me why I am getting `The GridView 'GridView1' fired event RowUpdating which wasn't handled.` error message

I have been able to work through the initial problem of not being able to insert records consistently but a new error message crops up.
Now, I am getting The GridView 'GridView1' fired event RowUpdating which wasn't handled.
This error occurs when I click the Update button to update a row of record.
First, I click Edit button. This exposes the Update/Cancel buttons.
When I click the Update button, I get the aforementioned error.
My first take was that gridview needed onRowUpdating but after adding (see markup code), still getting same error.
This is a bit frustrating.
Here is the code.
Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As GridViewUpdateEventArgs)
Dim dd As DropDownList = DirectCast(GridView1.Rows(e.RowIndex).FindControl("ddlstatus"), DropDownList)
e.NewValues("status") = dd.SelectedItem.Text
End Sub
Markup:
<asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1"
AutoGenerateColumns="False" DataKeyNames="reqnum" AllowPaging="True"
CellPadding="4" ForeColor="#333333" GridLines="None" Visible="True"
OnRowDataBound="gvRowDataBound" OnRowEditing="GridView1_RowEditing"
onrowupdating="GridView1_RowUpdating"
EnableViewState="False" AutoGenerateDeleteButton="True"
AutoGenerateEditButton="True">
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:BoundField DataField="rownum" HeaderText="rownum" InsertVisible="False" ReadOnly="True"
SortExpression="rownum" />
<asp:BoundField DataField="reqnum" HeaderText="reqnum" SortExpression="reqnum" />
<asp:BoundField DataField="reqrecdate" HeaderText="reqrecdate" SortExpression="reqrecdate" />
<asp:BoundField DataField="reqrecfrom" HeaderText="reqrecfrom" SortExpression="reqrecfrom" />
<asp:BoundField DataField="skillsets" HeaderText="skillsets" SortExpression="skillsets" />
<asp:BoundField DataField="application" HeaderText="application" SortExpression="application" />
<asp:BoundField DataField="hoursperweek" HeaderText="hoursperweek" SortExpression="hoursperweek" />
<asp:BoundField DataField="fromdate" HeaderText="fromdate" SortExpression="fromdate" />
<asp:BoundField DataField="todate" HeaderText="todate" SortExpression="todate" />
<%-- <asp:BoundField DataField="status" HeaderText="status" SortExpression="status" />--%>
<asp:TemplateField HeaderText="status">
<EditItemTemplate>
<asp:DropDownList id="ddlstatus" CssClass="dropdown" DataSourceID="DSforDDL" runat="server">
<asp:ListItem Text="none" Value=""></asp:ListItem>
<asp:ListItem>Not Started</asp:ListItem>
<asp:ListItem>Pending</asp:ListItem>
<asp:ListItem>Completed</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblstatus" runat="server" Text='<% #Bind("status") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="statusupdate" HeaderText="statusupdate" SortExpression="statusupdate" />
<asp:BoundField DataField="statusupby" HeaderText="statusupby" SortExpression="statusupby" />
</Columns>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT Distinct [rownum],[reqnum], [reqrecdate], [reqrecfrom], [skillsets], [application], [hoursperweek], [fromdate], [todate], [status], [statusupdate], [statusupby] FROM [Term] ORDER BY [reqnum]"
UpdateCommand="INSERT INTO Term(reum, reqrecdate, reqrecfrom, skillsets, application, hoursperweek, fromdate, todate, status, statusupby, statusupdate) VALUES (#reum,#reqrecdatelbltxt, #reqrecfromlbltxt, #skillsets, #application, #hoursperweek,#fromdate,#todate, #status, #lognametxt, #logdatetxt)"
<DeleteParameters>
<asp:Parameter Name="rownum" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="reqnum" Type="String" />
<asp:Parameter DbType="DateTime" Name="reqrecdate" />
<asp:Parameter Name="reqrecfrom" Type="String" />
<asp:Parameter Name="skillsets" Type="String" />
<asp:Parameter Name="application" Type="String" />
<asp:Parameter Name="hoursperweek" Type="Int32" />
<asp:Parameter DbType="DateTime" Name="fromdate" />
<asp:Parameter DbType="DateTime" Name="todate" />
<asp:Parameter Name="status" Type="String" />
<asp:Parameter DbType="DateTime" Name="statusupdate" />
<asp:Parameter Name="statusupby" Type="String" />
<asp:Parameter Name="rownum" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
Thanks a lot in advance for your assistance.
The gridView tracks handlers to ensure something has been added to deal with the update intentionally.
Unless you are Manually calling "AddHandler" somewhwere else in code, I don't see a handles claus on your event method that would intercept the event being raised.

Must Declare Scalar Variable when it is already defined, and Sytax error near 'nvarchar' when updating

Solution at the bottom.
I receive the following error when trying to update records:
Must declare Scalar Variable #PaymentTermID
Problem is, #PaymentTermID should be defined already in the Update parameters. The 2 functions for onrowdatabound and onrowupdate are tweaked versions of the ones found here for the DropDownList: GridViewRow.DataItem Property. Delete works fine.
No new lines are added, just names changed around. Any help would be appreciated, I am not exactly used to working with asp objects.
<asp:GridView ID="GridView1" onrowdatabound="GridView1_RowDataBound" onrowupdating="GridView1_RowUpdating" runat="server" AutoGenerateColumns="False" DataKeyNames="PaymentTermID" DataSourceID="SqlDataSource1" CellPadding="1" CellSpacing="2">
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:TemplateField HeaderText="Key Contract Date" SortExpression="Key Contract Date">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2" DataTextField="Key_Contract_Date" DataValueField="Key_Contract_Date" />
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:Production_DatabaseConnectionString %>"
SelectCommand="SELECT DISTINCT [Key Contract Date] AS Key_Contract_Date FROM [tblPRJ_PaymentTerms]" />
</EditItemTemplate>
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("[Key Contract Date]") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Due Date" HeaderText="Due Date" SortExpression="Due Date" />
<asp:BoundField DataField="Percent Due" HeaderText="Percent Due" SortExpression="Percent Due" />
<asp:BoundField DataField="Custom Description" HeaderText="Custom Description" SortExpression="Custom Description" />
</Columns>
<HeaderStyle Font-Bold="True" ForeColor="#666666" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Production_DatabaseConnectionString %>"
SelectCommand="SELECT * FROM [tblPRJ_PaymentTerms] WHERE ([Job Number] = #Job_Number)"
DeleteCommand="DELETE FROM [tblPRJ_PaymentTerms] WHERE [PaymentTermID] = #PaymentTermID"
InsertCommand="INSERT INTO [tblPRJ_PaymentTerms] ([Job Number], [Key Contract Date], [Due Date], [Percent Due], [Custom Description]) VALUES (#Job_Number, #Key_Contract_Date, #Due_Date, #Percent_Due, #Custom_Description)"
UpdateCommand="UPDATE [tblPRJ_PaymentTerms] SET [Job Number] = #Job_Number, [Key Contract Date] = #Key_Contract_Date, [Due Date] = #Due_Date, [Percent Due] = #Percent_Due, [Custom Description] = #Custom_Description WHERE [PaymentTermID] = #PaymentTermID">
<DeleteParameters>
<asp:Parameter Name="PaymentTermID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="Job_Number" Type="String" />
<asp:Parameter Name="Key_Contract_Date" Type="String" />
<asp:Parameter Name="Due_Date" Type="DateTime" />
<asp:Parameter Name="Percent_Due" Type="Decimal" />
<asp:Parameter Name="Custom_Description" Type="String" />
</InsertParameters>
<SelectParameters>
<asp:ControlParameter ControlID="txtCurrentJobNumber" Name="Job_Number" PropertyName="Text" Type="String" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="Job_Number" Type="String" />
<asp:Parameter Name="Key_Contract_Date" Type="String" />
<asp:Parameter Name="Due_Date" Type="DateTime" />
<asp:Parameter Name="Percent_Due" Type="Decimal" />
<asp:Parameter Name="Custom_Description" Type="String" />
<asp:Parameter Name="PaymentTermID" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
SOLUTION: There were multiple problems happening here. First and foremost, GuthMD was correct in his assessment of parameters needing a reference in terms of either a boundfield, templatefield, or other source (such as a control in the case of a control parameter). Simply creating an asp:boundfield for the PaymentTermID and setting the Visible property to false fixed the problem I posted about.
The other problem was that the database was setup poorly, and had spaces in column names. The OLEDB driver doesn't like that, and causes errors when you try to write back to the database and you have spaces in column names (even if it's encased in brackets []). After fixing the names in SQL, then revisiting our code and rewriting most of the SQL code for it, things started behaving as expected.
Thanks again for your help.
I've been looking through the MSDN documentation for Using Parameters, and it seems that for the binding to be created between the GridView and your SqlDataSource that your GridView is going to need to have BoundField elements corresponding to the Parameter elements.
Add the following to the <Columns> of your GridView:
<asp:BoundField DataField="Job_Number" Visible="false" />
<asp:BoundField DataField="Key_Contract_Date" Visible="false" />
<asp:BoundField DataField="Due_Date" Visible="false" />
<asp:BoundField DataField="Percent_Due" Visible="false" />
<asp:BoundField DataField="Custom_Description" Visible="false" />
<asp:BoundField DataField="PaymentTermID" Visible="false" />
1-The problem occurs when datasource is OleDb not SQLclient.
Change the DataSource1 to :
providerName="System.Data.SqlClient"
2-Make sure valid binding field in grid definition DataKeyNames="id_field"

How to use GridView edit functionality to modify a field that relies on another field

Sorry for the convoluted title, but that is the best way I could think to phrase it.
Basically, I have a column of data that is a URL (lets call it URL-A), and another that is hidden which is also a URL(URL-B). I have a function called ConvertURL(string URLin) in the codebehind that will take URL-A and turn it into URL-B.
So in this gridview, if someone were to edit an entry using the native gridview/datasource functionality and change URL-A, how do I get it to run this new URL-A through ConvertURL() and update the URL-B field?
Here is a simple representation of the code (not the actual code):
Code-behind function:
public string ConvertURL(string URLin)
{
Int32 iLocation = URLin.IndexOf("WWW.XYZ.COM");
if (iLocation >= 0)
{
string checkurl = URLin.Replace("WWW.XYZ.COM", "STAGING.XYZ.COM");
return checkurl;
}
else
{
return URLin;
}
}
Data-Source:
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:My_AppConnectionString %>"
SelectCommand="SELECT [URL_A], [URL_B], [URLName] FROM [My_App] WHERE ([IsActive] = #IsActive)"
OldValuesParameterFormatString="original_{0}"
UpdateCommand="UPDATE [My_App] SET [URL_A] = #URL_A, [URL_B] = #URL_B, [URLName] = #URLName, [IsActive] = #IsActive WHERE [ID] = #original_ID">
<SelectParameters>
<asp:Parameter DefaultValue="True" Name="IsActive" Type="Boolean" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="URL_A" Type="String" />
<asp:Parameter Name="URL_B" Type="String" />
<asp:Parameter Name="URLName" Type="String" />
<asp:Parameter Name="IsActive" Type="boolean" />
<asp:Parameter Name="original_ID" Type="Int32" />
<asp:Parameter Name="original_URL_A" Type="String" />
<asp:Parameter Name="original_URL_B" Type="String" />
<asp:Parameter Name="original_URLName" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
And Lastly the GridView:
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
onrowediting="GridView1_RowEditing"
AutoGenerateColumns="False" CellPadding="3" DataKeyNames="ID"
DataSourceID="SqlDataSource1" EnableModelValidation="False" ForeColor="Black"
GridLines="Vertical" AllowSorting="True" BackColor="White"
BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px"
AutoGenerateEditButton="True" CausesValidation="false">
<AlternatingRowStyle BackColor="#CCCCCC" />
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False"
ReadOnly="True" SortExpression="ID" Visible="False" />
<asp:BoundField DataField="URL_A" HeaderText="URL A"
SortExpression="URL_A" />
<asp:BoundField DataField="URL_B" HeaderText="URL B"
SortExpression="URL_B" **Visible="False"** />
<asp:BoundField DataField="URLName" HeaderText="URL Name"
SortExpression="URLName" />
<asp:CheckBoxField DataField="IsActive" HeaderText="Active"
SortExpression="IsActive" />
</Columns>
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
</asp:GridView>
So to summarize: A user will see a gridview with 3 fields to edit, one of which is URL_A (URL_B is hidden). When they hit edit and update the URL_A field I want to run URL_A through the ConvertURL() function and use that output as the data for URL_B when the update is performed.
I appreciate the help in advance!
Use the RowUpdating event of the grid view and change the new value for URL_B. In that event you will have access to the old values of the row as well as the new values. You can change the new values before they are sent to the data source for the actual update.
Add the event handler to the grid view in the ASPX:
<asp:GridView ID="GridView1" runat="server"
...
OnRowUpdating="GridView1_RowUpdating">
And in the code file handle the event:
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
// Find the current value for URL_A
string urlA = (string)e.NewValues["URL_A"];
// Get the corresponding value for URL_B from the method
string urlB = ConvertURL(urlA);
// Set the new value for the URL_B column before it's sent to the SqlDataSource
e.NewValues["URL_B"] = urlB;
}

Telerik RadGrid Add/Edit Row Performance Issue

In a Telerik RadGrid, the user has the ability to add a row and edit an existing one. It appears that the grids actually force a postback to occur before the UI controls are rendered on the screen. I'm noticing a second to two seconds delay from the time the button is clicked to the time the controls appear. This seems about a second to two seconds too long. Here is my code, I'm not exactly sure what the bug is.
I apologize in advance for the "whatz wrongz with me codez post", but this seems like the easiest way to go about this one. Again, I have a performance issue and would like to figure out how to solve it in terms of what code needs to be tweaked.....
<asp:UpdatePanel ID="upPhone" runat="server">
<contenttemplate>
<telerik:RadGrid runat="server" ID="gridPhone" DataSourceID="dsPhone" AutoGenerateColumns="False"
Width="100%" AllowAutomaticDeletes="True" AllowAutomaticInserts="True"
GridLines="None" Skin="Vista" AllowAutomaticUpdates="True"
ondatabound="gridPhone_DataBound" onitemdeleted="gridPhone_ItemDeleted"
oniteminserted="gridPhone_ItemInserted"
onitemupdated="gridPhone_ItemUpdated"
onneeddatasource="gridPhone_NeedDataSource">
<MasterTableView DataKeyNames="phone_id" CommandItemDisplay="Top"
EditMode="InPlace" AllowFilteringByColumn="False">
<Columns>
<telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
<ItemStyle CssClass="MyImageButton" />
</telerik:GridEditCommandColumn>
<telerik:GridBoundColumn DataField="phone_id" ReadOnly="true" UniqueName="phone_id"
Visible="false">
</telerik:GridBoundColumn>
<telerik:GridDropDownColumn DataField="d_phone_type_id" DataSourceID="dsPhoneType"
UniqueName="d_phone_type_id" DataType="System.Int32" ListValueField="d_phone_type_id"
ListTextField="name" HeaderText="Type">
</telerik:GridDropDownColumn>
<telerik:GridTemplateColumn HeaderText="Number" SortExpression="number" UniqueName="number">
<ItemTemplate>
<asp:Label runat="server" ID="lblPhoneNumber" Text='<%# Eval("number", "{0:(###) ###-####}") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtNumber" MaxLength="10" runat="server" Text='<%# Bind("number") %>'></asp:TextBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="description" UniqueName="description" HeaderText="Description">
</telerik:GridBoundColumn>
<telerik:GridCheckBoxColumn DataField="isprimary" UniqueName="isprimary" HeaderText="Primary"
DataType="System.Int16">
</telerik:GridCheckBoxColumn>
<telerik:GridButtonColumn ConfirmText="Delete this number?" ConfirmDialogType="RadWindow"
ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
UniqueName="DeleteColumn">
<ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
</telerik:GridButtonColumn>
</Columns>
<EditFormSettings>
<EditColumn UniqueName="EditCommandColumn1">
</EditColumn>
</EditFormSettings>
</MasterTableView>
<ClientSettings>
<Selecting AllowRowSelect="True" />
</ClientSettings>
</telerik:RadGrid>
<asp:ObjectDataSource ID="dsPhoneType" runat="server"
OldValuesParameterFormatString="original_{0}" SelectMethod="GetPhoneTypes"
TypeName="DataAccess"></asp:ObjectDataSource>
<asp:SqlDataSource ID="dsPhone" runat="server" ConnectionString="<%$ ConnectionStrings:TBD %>"
DeleteCommand="DELETE FROM [phone] WHERE [phone_id] = #phone_id" InsertCommand="INSERT INTO [phone] ([person_id],[d_phone_type_id], [number], [description], [isprimary]) VALUES (#person_id,#d_phone_type_id, #number, #description, #isprimary)"
SelectCommand="get_PhoneById" UpdateCommand="UPDATE [phone] SET [d_phone_type_id] = #d_phone_type_id, [number] = #number, [description] = #description, [isprimary] = #isprimary WHERE [phone_id] = #phone_id"
SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter ControlID="lblID" Name="person_id" PropertyName="Text" Type="Int32" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="phone_id" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="d_phone_type_id" Type="Int32" />
<asp:Parameter Name="number" Type="Int64" />
<asp:Parameter Name="description" Type="String" />
<asp:Parameter Name="isprimary" Type="Boolean" />
<asp:Parameter Name="phone_id" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:ControlParameter ControlID="lblID" Name="person_id" PropertyName="Text" />
<asp:Parameter Name="d_phone_type_id" Type="Int32" />
<asp:Parameter Name="number" Type="Int64" />
<asp:Parameter Name="description" Type="String" />
<asp:Parameter Name="isprimary" Type="Boolean" />
</InsertParameters>
</asp:SqlDataSource>
</contenttemplate>
</asp:UpdatePanel>
Just a couple of things to check:
Are you duplicating the bind behaviour in the gridPhone_NeedDataSource event, your ItemUpdated, Deleted and Inserted events, and the native Rad Grid binding behviour (by using a asp:SqlDataSource control)? It would be useful to see your code-behind to see if you are or not.
How many records do you have in the grid? I find if I have a large number of items in the Grid and have some of the advanced features turned on (I've noticed you've got row selecting enabled) the grid grinds to a halt.
If none of these work/apply to your situation then it maybe worth checking the performance section of their site.
I am seeing that you are using DataSourceID="dsPhone" and onneeddatasource="gridPhone_NeedDataSource"
not sure if you need both. Also make sure you dont do a DataBind() else where in your code (page_Load or any other place) since you already have OnNeedDataSource event attached to the grid

Resources