Hi all,
I am using a webusercontrol for my insert / edit of my radgrid. The insert seems to work fine, except the window doesn't close. After the save, if I click the close X then everything is fine - but it should do that automatically. The other problem is that my edit doesn't work - doesn't pull information in. I'm sure that's because I'm not doing anything to bind it.
So - first question - my .ascx file is using a FormView control and does all of the binding like a normal page would. Is that correct? I really couldn't find a simple example of how to do this.
If 'yes' and I have done that part right - then how do I get my edit to tie to my grid?
Thanks so much. I've included code here:
1. Grid:
2. My user control looks like this:
Thanks for your help!
I am using a webusercontrol for my insert / edit of my radgrid. The insert seems to work fine, except the window doesn't close. After the save, if I click the close X then everything is fine - but it should do that automatically. The other problem is that my edit doesn't work - doesn't pull information in. I'm sure that's because I'm not doing anything to bind it.
So - first question - my .ascx file is using a FormView control and does all of the binding like a normal page would. Is that correct? I really couldn't find a simple example of how to do this.
If 'yes' and I have done that part right - then how do I get my edit to tie to my grid?
Thanks so much. I've included code here:
1. Grid:
<
telerik:RadGrid
runat
=
"server"
ID
=
"gvPatientSearch"
DataSourceID
=
"dsPatients"
AllowAutomaticInserts
=
"true"
>
<
ClientSettings
>
<
ClientEvents
OnPopUpShowing
=
"PopUpShowing"
/>
</
ClientSettings
>
<
MasterTableView
DataKeyNames
=
"patientID"
CommandItemDisplay
=
"Top"
Width
=
"100%"
EditMode
=
"PopUp"
>
<
EditFormSettings
UserControlName
=
"~/App_Assets/Controls/patientControl.ascx"
EditFormType
=
"WebUserControl"
CaptionDataField
=
"lastName"
CaptionFormatString
=
"Edit Patient Record for {0}"
InsertCaption
=
"New Patient"
FormStyle-Width
=
"600px"
>
</
EditFormSettings
>
<
CommandItemSettings
ShowAddNewRecordButton
=
"true"
AddNewRecordText
=
"Add New Patient"
/>
<
Columns
>
...
<
telerik:GridEditCommandColumn
/>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
2. My user control looks like this:
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="patientControl.ascx.vb" Inherits="App_Assets_Controls_patientControl" %>
<
div
align
=
"center"
>
<
asp:FormView
runat
=
"server"
ID
=
"fvPatients"
DataKeyNames
=
"patientID"
DataSourceID
=
"dsPatients"
DefaultMode
=
"Insert"
>
<
EditItemTemplate
>
<
table
class
=
"searchTable"
style
=
"border: 1px solid #2a5690; background-color: #f7f5f0;"
cellpadding
=
"3"
cellspacing
=
"1"
width
=
"99%"
>
<
tr
>
<
td
align
=
"right"
>Last Name:</
td
>
<
td
>
<
telerik:RadTextBox
runat
=
"server"
ID
=
"txtLastName"
Text='<%# Bind("lastName") %>' MaxLength="50" />
<
asp:RequiredFieldValidator
ID
=
"RequiredFieldValidator2"
runat
=
"server"
ControlToValidate
=
"txtLastName"
CssClass
=
"errorMessage"
>«</
asp:RequiredFieldValidator
>
</
td
>
</
tr
>
<
tr
>
<
td
align
=
"right"
>First Name:</
td
>
<
td
>
<
telerik:RadTextBox
runat
=
"server"
ID
=
"txtFirstName"
Text='<%# Bind("firstName") %>' MaxLength="50" />
<
asp:RequiredFieldValidator
ID
=
"RequiredFieldValidator3"
runat
=
"server"
ControlToValidate
=
"txtFirstName"
CssClass
=
"errorMessage"
>«</
asp:RequiredFieldValidator
>
</
td
>
</
tr
>
<
tr
>
<
td
align
=
"right"
>Middle Name:</
td
>
<
td
>
<
telerik:RadTextBox
runat
=
"server"
ID
=
"txtMiddleName"
Text='<%# Bind("middleName") %>' MaxLength="50" />
</
td
>
</
tr
>
<
tr
>
<
td
align
=
"right"
valign
=
"top"
>Sex:</
td
>
<
td
valign
=
"top"
>
<
asp:RadioButtonList
runat
=
"server"
RepeatDirection
=
"Horizontal"
ID
=
"cboSex"
SelectedValue='<%# Bind("sex") %>'>
<
asp:ListItem
Text
=
"Male"
Value
=
"M"
/>
<
asp:ListItem
Text
=
"Female"
Value
=
"F"
/>
</
asp:RadioButtonList
>
<
asp:RequiredFieldValidator
ID
=
"RequiredFieldValidator1"
runat
=
"server"
ControlToValidate
=
"cboSex"
CssClass
=
"errorMessage"
>please choose sex</
asp:RequiredFieldValidator
>
</
td
>
</
tr
>
<
tr
>
<
td
align
=
"right"
>Date of Birth:</
td
>
<
td
>
<
telerik:RadDateInput
MinDate
=
"01/01/1900"
runat
=
"server"
ID
=
"dteDateOfBirth"
SelectedDate='<%# Bind("dateOfBirth") %>' />
<
asp:RequiredFieldValidator
ID
=
"RequiredFieldValidator4"
runat
=
"server"
ControlToValidate
=
"dteDateOfBirth"
CssClass
=
"errorMessage"
>«</
asp:RequiredFieldValidator
>
</
td
>
</
tr
>
<
tr
>
<
td
align
=
"right"
>SSN:</
td
>
<
td
>
<
telerik:RadMaskedTextBox
ID
=
"txtSSN"
runat
=
"server"
Mask
=
"###-##-####"
TextWithLiterals
=
"-"
Width
=
"75px"
Text='<%# Bind("ssn") %>' />
<
asp:RequiredFieldValidator
ID
=
"RequiredFieldValidator5"
runat
=
"server"
ControlToValidate
=
"txtSSN"
CssClass
=
"errorMessage"
>«</
asp:RequiredFieldValidator
>
</
td
>
</
tr
>
<
tr
>
<
td
align
=
"right"
>Phone Number:</
td
>
<
td
>
<
telerik:RadMaskedTextBox
runat
=
"server"
ID
=
"txtPhoneNumber"
Mask
=
"###-###-####"
TextWithLiterals
=
"-"
MaxLength
=
"15"
Text='<%# Bind("phoneNumber") %>' />
</
td
>
</
tr
>
<
tr
>
<
td
align
=
"right"
>Alternate (Cell) Phone Number:</
td
>
<
td
><
telerik:RadMaskedTextBox
runat
=
"server"
ID
=
"txtPhoneNumber2"
Mask
=
"###-###-####"
TextWithLiterals
=
"-"
MaxLength
=
"15"
Text='<%# Bind("phoneNumber2") %>' /></
td
>
</
tr
>
<
tr
>
<
td
align
=
"right"
>Address Line 1:</
td
>
<
td
><
telerik:RadTextBox
runat
=
"server"
ID
=
"txtAddressLine1"
MaxLength
=
"150"
Text='<%# Bind("addressLine1") %>' /></
td
>
</
tr
>
<
tr
>
<
td
align
=
"right"
>Address Line 2:</
td
>
<
td
><
telerik:RadTextBox
runat
=
"server"
ID
=
"txtAddressLine2"
MaxLength
=
"150"
Text='<%# Bind("addressLine2") %>' /></
td
>
</
tr
>
<
tr
>
<
td
align
=
"right"
>City:</
td
>
<
td
><
telerik:RadTextBox
runat
=
"server"
ID
=
"txtCity"
EmptyMessage
=
"enter city"
MaxLength
=
"50"
Text='<%# Bind("city") %>' /></
td
>
</
tr
>
<
tr
>
<
td
align
=
"right"
>State:</
td
>
<
td
><
telerik:RadTextBox
runat
=
"server"
ID
=
"txtState"
EmptyMessage
=
"enter state"
MaxLength
=
"2"
Text='<%# Bind("state") %>' /></
td
>
</
tr
>
<
tr
>
<
td
align
=
"right"
>Zip Code:</
td
>
<
td
><
telerik:RadTextBox
runat
=
"server"
ID
=
"txtZipCode"
EmptyMessage
=
"enter zip code"
MaxLength
=
"10"
Text='<%# Bind("zipCode") %>' /></
td
>
</
tr
>
<
tr
>
<
td
align
=
"right"
>Email Address:</
td
>
<
td
><
telerik:RadTextBox
runat
=
"server"
ID
=
"txtEmailAddress"
Text='<%# Bind("emailAddress") %>' /></
td
>
</
tr
>
<
tr
>
<
td
align
=
"right"
>Hospital Patient ID:</
td
>
<
td
><
telerik:RadTextBox
runat
=
"server"
ID
=
"txtHospitalPatientID"
Text='<%# Bind("hospitalPatientID") %>' /></
td
>
</
tr
>
<
tr
>
<
td
></
td
>
<
td
><
telerik:RadButton
CommandName
=
"Insert"
runat
=
"server"
ID
=
"btnSave"
Text
=
"Add Patient"
/></
td
>
</
tr
>
</
table
>
</
EditItemTemplate
>
</
asp:FormView
>
</
div
>
<
asp:SqlDataSource
runat
=
"server"
ID
=
"dsPatients"
SelectCommandType
=
"StoredProcedure"
SelectCommand
=
"sp_Patients"
InsertCommandType
=
"StoredProcedure"
InsertCommand
=
"sp_Patients"
UpdateCommandType
=
"StoredProcedure"
UpdateCommand
=
"sp_Patients"
>
<
SelectParameters
>
<
asp:Parameter
Name
=
"Action"
DefaultValue
=
"SELECT"
/>
<
asp:QueryStringParameter
Name
=
"patientID"
QueryStringField
=
"patientID"
/>
</
SelectParameters
>
<
InsertParameters
>
<
asp:Parameter
Name
=
"Action"
DefaultValue
=
"INSERT"
/>
<
asp:CookieParameter
Name
=
"lastUpdatedBy"
CookieName
=
"userName"
/>
</
InsertParameters
>
<
UpdateParameters
>
<
asp:Parameter
Name
=
"Action"
DefaultValue
=
"UPDATE"
/>
<
asp:CookieParameter
Name
=
"lastUpdatedBy"
CookieName
=
"userName"
/>
</
UpdateParameters
>
</
asp:SqlDataSource
>
Thanks for your help!