how to click button load gridview but disload page web - asp.net

I have a problem with ASPxGridView.
I have a aspxgridview1 contain button.
aspxgridview2 contain data.
when I pressed the button. data will be displayed on the aspgridview2 corresponding "ID" of aspxgridview1 but without reloading the page.
this is following aspxgridview1
<dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" KeyFieldName="Province_Id">
<Columns>
<dx:GridViewCommandColumn VisibleIndex="0">
<EditButton Visible="True">
</EditButton>
<ClearFilterButton Visible="True">
</ClearFilterButton>
<CustomButtons>
<dx:GridViewCommandColumnCustomButton ID="show" Text="show">
</dx:GridViewCommandColumnCustomButton>
</CustomButtons>
</dx:GridViewCommandColumn>
<dx:GridViewDataTextColumn FieldName="Province_Id" ReadOnly="True" VisibleIndex="1">
<EditFormSettings Visible="False" />
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="Name" VisibleIndex="2">
</dx:GridViewDataTextColumn>
<dx:GridViewDataButtonEditColumn VisibleIndex="4">
</dx:GridViewDataButtonEditColumn>
</Columns>
<SettingsBehavior AllowFocusedRow="True" />
<Settings ShowFilterRow="True" ShowFooter="True" ShowGroupPanel="True" ShowTitlePanel="True" />
</dx:ASPxGridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TravelConnectionString %>" DeleteCommand="DELETE FROM [Province] WHERE [Province_Id] = #Province_Id" InsertCommand="INSERT INTO [Province] ([Name]) VALUES (#Name)" SelectCommand="SELECT * FROM [Province]" UpdateCommand="UPDATE [Province] SET [Name] = #Name WHERE [Province_Id] = #Province_Id">
<DeleteParameters>
<asp:Parameter Name="Province_Id" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="Name" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="Province_Id" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>

If you're set on using the ASPxGridViews, the best you can do is wrap both controls in UpdatePanels. If you don't like that solution, you'll need to look into using ajax to get the data after clicking a button.

Related

GridView is not displaying when page is loaded

Hello I am working on a project for school. I am building a page that has a DropDownList that is populated through a SQLDataSource. It displays the names of classes from a table in my database called 'COURSES', when one of the classes is selected a GridView is supposed to display data from tables 'STUDENTS' and 'GRADES'. When I make a selection the GridView does not display at all. I think the problem is in my WHERE clause of the SELECT command. Any help would be greatly appreciated!
Here is my aspx file:
<%# Page Language="C#" AutoEventWireup="true" CodeFile="ClassStudentEdit.aspx.cs" Inherits="ClassStudentEdit" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Students</title>
<link type="text/css" rel="stylesheet" href="termproject.css" />
</head>
<body>
<form id="form1" runat="server">
<div id="main">
Course Name: <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="CourseName" DataValueField="CourseID"></asp:DropDownList>
<br />
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:PayablesConnectionString %>" SelectCommand="SELECT [CourseName], [CourseID] FROM [COURSES] ORDER BY [CourseName]"></asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource2" DataKeyNames="CourseID" AllowPaging="True" AllowSorting="True">
<Columns>
<asp:CommandField ButtonType="Button" ShowSelectButton="True" />
<asp:BoundField DataField="StudentID" HeaderText="StudentID" SortExpression="StudentID" InsertVisible="False" ReadOnly="True" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />
<asp:BoundField DataField="Grade" HeaderText="Grade" SortExpression="Grade" />
</Columns>
</asp:GridView>
<br />
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:PayablesConnectionString %>" SelectCommand="SELECT COURSES.CourseID, GRADES.Grade, STUDENTS.StudentID, STUDENTS.Title, STUDENTS.FirstName, STUDENTS.LastName FROM COURSES INNER JOIN GRADES ON COURSES.CourseID = GRADES.CourseID INNER JOIN STUDENTS ON GRADES.StudentID = STUDENTS.StudentID WHERE (COURSES.CourseName = #CourseID)">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="CourseID" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px" AutoGenerateRows="False" DataKeyNames="StudentID" DataSourceID="SqlDataSource3">
<Fields>
<asp:BoundField DataField="StudentID" HeaderText="StudentID" InsertVisible="False" ReadOnly="True" SortExpression="StudentID" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />
<asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
<asp:CommandField ShowEditButton="True" />
</Fields>
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConflictDetection="CompareAllValues" ConnectionString="<%$ ConnectionStrings:PayablesConnectionString %>" DeleteCommand="DELETE FROM [STUDENTS] WHERE [StudentID] = #original_StudentID AND (([Title] = #original_Title) OR ([Title] IS NULL AND #original_Title IS NULL)) AND (([FirstName] = #original_FirstName) OR ([FirstName] IS NULL AND #original_FirstName IS NULL)) AND (([LastName] = #original_LastName) OR ([LastName] IS NULL AND #original_LastName IS NULL)) AND (([Address] = #original_Address) OR ([Address] IS NULL AND #original_Address IS NULL))" InsertCommand="INSERT INTO [STUDENTS] ([Title], [FirstName], [LastName], [Address]) VALUES (#Title, #FirstName, #LastName, #Address)" OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [STUDENTS] WHERE ([StudentID] = #StudentID)" UpdateCommand="UPDATE [STUDENTS] SET [Title] = #Title, [FirstName] = #FirstName, [LastName] = #LastName, [Address] = #Address WHERE [StudentID] = #original_StudentID AND (([Title] = #original_Title) OR ([Title] IS NULL AND #original_Title IS NULL)) AND (([FirstName] = #original_FirstName) OR ([FirstName] IS NULL AND #original_FirstName IS NULL)) AND (([LastName] = #original_LastName) OR ([LastName] IS NULL AND #original_LastName IS NULL)) AND (([Address] = #original_Address) OR ([Address] IS NULL AND #original_Address IS NULL))">
<DeleteParameters>
<asp:Parameter Name="original_StudentID" Type="Int32" />
<asp:Parameter Name="original_Title" Type="String" />
<asp:Parameter Name="original_FirstName" Type="String" />
<asp:Parameter Name="original_LastName" Type="String" />
<asp:Parameter Name="original_Address" Type="String" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter Name="Address" Type="String" />
</InsertParameters>
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="StudentID" PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter Name="Address" Type="String" />
<asp:Parameter Name="original_StudentID" Type="Int32" />
<asp:Parameter Name="original_Title" Type="String" />
<asp:Parameter Name="original_FirstName" Type="String" />
<asp:Parameter Name="original_LastName" Type="String" />
<asp:Parameter Name="original_Address" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
<br />
<br />
</div>
</form>
</body>
</html>
This is your sql:
SELECT Courses.Courseid,
Grades.Grade,
Students.Studentid,
Students.Title,
Students.Firstname,
Students.Lastname
FROM Courses
INNER JOIN Grades
ON Courses.Courseid = Grades.Courseid
INNER JOIN Students
ON Grades.Studentid = Students.Studentid
WHERE ( Courses.Coursename = #CourseID )
Isn't it Courses.Courseid instead of Courses.Coursename? So:
WHERE ( Courses.Courseid = #CourseID )
( one of the reasons why i avoid declarative datasource controls )

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.

ASP.NET: Use ID from query against a SQL Server view used in a GridView to control DetailsView that queries a table

Please forgive my ignorance. I have a done a bit of web programming but am new to ASP.NET and find it mystifying when trying to do something not out of the box.
I have a GridView that gets its data from a SQL Server view. I have a DetailsView that needs to manipulate data in a table. I cannot figure out how to link the GridView to the DetailsView correctly.
Below is the code for the section of the aspx page that contains the GridView and DetailsView. The latest error in an endless procession of errors is: Must declare the scalar variable "#ID".
I would appreciate any help that anyone can offer. Thanks.
<asp:GridView ID="gvVendorContacts" runat="server" AutoGenerateColumns="False"
DataSourceID="dsApplications_Contacts" AllowSorting="True" CellPadding="4" CellSpacing="2" AutoGenerateSelectButton="True" DataKeyNames="ContactID"
onselectedindexchanged="gvVendorContacts_SelectedIndexChanged">
<AlternatingRowStyle BackColor="#E8F3FF" />
<Columns>
<asp:BoundField DataField="FullName" HeaderText="Name" ReadOnly="True"
SortExpression="FullName" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:BoundField DataField="Role" HeaderText="Role" SortExpression="Role" />
<asp:BoundField DataField="Office Phone" HeaderText="Office Phone"
SortExpression="Office Phone" />
<asp:BoundField DataField="Mobile Phone" HeaderText="Mobile Phone"
SortExpression="Mobile Phone" />
<asp:TemplateField HeaderText="Email" SortExpression="Email">
<ItemTemplate>
<%#Eval("Email")%>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="dsApplications_Contacts" runat="server"
ConnectionString="<%$ ConnectionStrings:MDSConnectionString %>"
SelectCommand="SELECT [ApplicationID], [ContactID], [FName], [LName], [FullName], [Title], [Role], [OfficePhone] As [Office Phone], [MobilePhone] As [Mobile Phone], [Email] FROM [vw_Applications_Contacts] WHERE ApplicationName = 'Bloomberg'">
</asp:SqlDataSource>
<asp:DetailsView ID="dvVendorContacts" runat="server" AutoGenerateRows="False"
DataKeyNames="ID" DataSourceID="dsVendorContacts" Height="100px"
Width="200px" BackColor="White" BorderColor="#CC9966" BorderStyle="None"
BorderWidth="1px" CellPadding="4">
<EditRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
<Fields>
<asp:BoundField DataField="ContactID" HeaderText="ID" InsertVisible="False"
ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="FName" HeaderText="FName" SortExpression="FName" />
<asp:BoundField DataField="LName" HeaderText="LName" SortExpression="LName" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:BoundField DataField="Role" HeaderText="Role" SortExpression="Role" />
<asp:BoundField DataField="OfficePhone" HeaderText="OfficePhone"
SortExpression="OfficePhone" />
<asp:BoundField DataField="MobilePhone" HeaderText="MobilePhone"
SortExpression="MobilePhone" />
<asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
</Fields>
<FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
<PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
<RowStyle BackColor="White" ForeColor="#330099" />
</asp:DetailsView>
<asp:SqlDataSource ID="dsVendorContacts" runat="server"
ConnectionString="<%$ ConnectionStrings:MDSConnectionString %>"
DeleteCommand="DELETE FROM [Contacts] WHERE [ID] = #ID"
InsertCommand="INSERT INTO [Contacts] ([FName], [LName], [Title], [Role], [OfficePhone], [MobilePhone], [Email]) VALUES (#FName, #LName, #Title, #Role, #OfficePhone, #MobilePhone, #Email)"
SelectCommand="SELECT [ID], [FName], [LName], [Title], [Role], [OfficePhone], [MobilePhone], [Email] FROM [Contacts] WHERE ([ID] = #ID)"
UpdateCommand="UPDATE [Contacts] SET [FName] = #FName, [LName] = #LName, [Title] = #Title, [Role] = #Role, [OfficePhone] = #OfficePhone, [MobilePhone] = #MobilePhone, [Email] = #Email WHERE [ID] = #ID">
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="FName" Type="String" />
<asp:Parameter Name="LName" Type="String" />
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="Role" Type="String" />
<asp:Parameter Name="OfficePhone" Type="String" />
<asp:Parameter Name="MobilePhone" Type="String" />
<asp:Parameter Name="Email" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="FName" Type="String" />
<asp:Parameter Name="LName" Type="String" />
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="Role" Type="String" />
<asp:Parameter Name="OfficePhone" Type="String" />
<asp:Parameter Name="MobilePhone" Type="String" />
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="ID" Type="Int32" />
</UpdateParameters>
<SelectParameters>
<asp:ControlParameter ControlID="gvVendorContacts" DefaultValue="NULL"
Name="ContactID" PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
Looks like your select statement is expecting #ID but your SelectParameter is ContactId.

passing dropdown value to update parameter for ASP.Net Gridview

I have a gridview that, when in edit mode, I use a dropdown to load all provinces, however, when I change the province and click update, my page crashes...I'm not sending the province parameter to the gridview's updateparameters properly...here's my code, someone please help..
<asp:GridView runat="server" ID="gvUsers" DataKeyNames="UserID" BackColor="#eeeeee" Width="85%"
HorizontalAlign="Center"
Font-Bold="False" Font-Names="Verdana"
Font-Size="10pt" AutoGenerateColumns="False"
OnRowDataBound="gvUsers_RowDataBound"
OnRowDeleting="gvUsers_RowDeleting" >
<HeaderStyle BackColor="#904601" ForeColor="White"
Font-Bold="True" HorizontalAlign="Left" />
<SelectedRowStyle BackColor="Yellow" />
<AlternatingRowStyle BackColor="White" Font-Bold="false" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="LinkButton2"
CommandArgument='<%# Eval("UserID") %>'
CommandName="Select" runat="server">
Select</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="UserID" Visible="False" />
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("FirstName") %>'></asp:Label>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("LastName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Delete?">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1"
CommandArgument='<%# Eval("UserID") %>'
CommandName="Delete" runat="server">
Delete</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle HorizontalAlign="Left" />
</asp:GridView><br /><br />
<asp:DetailsView runat="server" ID="dvUser" DataSourceID="SqlDataSource1" AutoGenerateRows="False" Width="85%" DataKeyNames="UserID"
HorizontalAlign="Center" AutoGenerateInsertButton="True" AutoGenerateEditButton="True" OnItemInserted="dvUsers_ItemInserted" >
<Fields>
<asp:BoundField DataField="UserID" Visible="False" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />
<asp:BoundField DataField="UserName" HeaderText="UserName" ReadOnly="true" SortExpression="UserName" />
<asp:TemplateField HeaderText="Password">
<ItemTemplate>
<asp:Label runat="server" ID="lblPassword" Text="●●●●●●●●●"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtPassword" TextMode="Password" Text='<%# Bind("Password") %>'>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Birthdate" SortExpression="Birthdate">
<EditItemTemplate>
<asp:TextBox runat="server" ID="Birthdate" Text='<%# Bind("Birthdate") %>' ></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label runat="Server" ID="lblBirthdate" Text='<%# Bind("Birthdate") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
<asp:BoundField DataField="Apt" HeaderText="Apt" SortExpression="Apt" />
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
<asp:TemplateField HeaderText="Province">
<ItemTemplate>
<asp:Label runat="server" ID="lblProvince" Text='<%# Eval("ProvName") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList runat="server" ID="ddlProvince" DataValueField="ProvinceID" DataSourceID="SqlDataSource2" DataTextField="Province"></asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="PostalCode" HeaderText="PostalCode" SortExpression="PostalCode" />
<asp:BoundField DataField="PhoneNum" HeaderText="PhoneNum" SortExpression="PhoneNum" />
<asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
<asp:CheckBoxField DataField="ynAdminUser" HeaderText="ynAdminUser" SortExpression="ynAdminUser" />
</Fields>
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource2"
runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT ProvinceID, Province FROM tblProvince"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource1"
runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT a.UserID, a.FirstName, a.LastName, a.UserName, a.Password, a.Birthdate, a.Address, a.Apt, a.City, a.Province, b.Province as 'ProvName',
a.PostalCode, a.PhoneNum, a.Email, a.ynAdminUser
FROM tblUser a
INNER JOIN tblProvince B ON A.Province = B.ProvinceID
WHERE (a.UserID = #UserID) AND (a.ynDelete = 0)"
InsertCommand="INSERT INTO tblUser(FirstName, LastName, UserName, Password, Birthdate, Address, Apt, City, Province, PostalCode, Email, PhoneNum, ynAdminUser, ynDelete) VALUES (#FirstName, #LastName, #UserName, #Password, #Birthdate, #Address, #Apt, #City, #Province, #PostalCode, #Email, #PhoneNum, #ynAdminUser, 0)"
UpdateCommand="UPDATE tblUser SET FirstName = #FirstName, LastName = #LastName, Birthdate = #Birthdate, Address = #Address, Apt = #Apt, City = #City, Province = #Province, PostalCode = #PostalCode, PhoneNum = #PhoneNum, Email = #Email, ynAdminUser = #ynAdminUser WHERE (UserID = #UserID)">
<SelectParameters>
<asp:ControlParameter ControlID="gvUsers" Name="UserID" PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter DbType="DateTime" Name="BirthDate" />
<asp:Parameter Name="Address" Type="String" />
<asp:Parameter Name="Apt" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:ControlParameter Name="Province" ControlID="ddlProvince" PropertyName="SelectedValue" Type="Int32" />
<asp:Parameter Name="PhoneNum" Type="String" />
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="ynAdminUser" Type="Boolean" />
<asp:Parameter Name="UserID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter Name="UserName" Type="String" />
<asp:Parameter Name="Password" Type="String" />
<asp:Parameter DbType="DateTime" Name="Birthdate" />
<asp:Parameter Name="Address" Type="String" />
<asp:Parameter Name="Apt" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="Province" Type="Int32" />
<asp:Parameter Name="PostalCode" Type="String" />
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="PhoneNum" Type="String" />
<asp:Parameter Name="ynAdminUser" Type="Boolean" />
</InsertParameters>
</asp:SqlDataSource>
You don't need the control binding:
<asp:ControlParameter Name="Province" ControlID="ddlProvince" PropertyName="SelectedValue" Type="Int32" />
Instead, use a regualar parameter like your others and add the following binding to your drop-down list for the edit mode of the gridview:
SelectedValue=<%#Bind("Province")%>
I realize this is a really old question, and I hope you found your answer.
Looking at your markup, though, I want to say your connection strings were never filled out:
runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
I am not the strongest when it comes to ASP.NET databinding in the markup code, but I am pretty sure your connection string needs to point to an actual string name in your web.Config file's ConnectionStrings section:
<connectionStrings>
<clear />
<add name="Mark1" connectionString="Data Source=localhost;Initial Catalog=Table1;Integrated Security=True;" providerName="System.Data.SqlClient" />
</connectionStrings>
Use whatever your actual connection string is, though.
Now, your markup should be written as:
runat="server" ConnectionString="<%$ ConnectionStrings:Mark1 %>"
Again, I'm new to this. I found this only while trying to search for ways to solve my own problems.
If this is wrong (possible), someone just let me know what I did wrong and I'll delete it.

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