I have a GridView with its columns being TextBoxes and after user made modifications to data within GridView I have a "Commit" Button thats located outside the GridView and also located under a different Content within the page... How do I set the Validator to work even though I have the validator set correctly but when I click on the "Commit" button it doesn't check for the validation and I believe its because the button is not inside the GridView or UpdatePanel... Is there a way to get around that? or A better approach?
Thanks for your help in advance.
Please select a Test from the dropdown below.<br />
<asp:DropDownList ID="ddlResult" runat="server"
onselectedindexchanged="ddlResult_SelectedIndexChanged"
AutoPostBack="True" CausesValidation="false">
</asp:DropDownList>
<br />
<asp:UpdatePanel ID="upGrid" runat="server">
<ContentTemplate>
<asp:GridView ID="grdResults" runat="server"
CssClass="gridview"
RowStyle-CssClass="gridview_itm"
AlternatingRowStyle-CssClass="gridview_aitm"
HeaderStyle-CssClass="gridview_hdr"
Width="100%" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField HeaderText="Test">
<ItemTemplate>
<asp:Label ID="lblTest" runat="server" Text='<%#Eval("Test")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Result">
<ItemTemplate>
<asp:TextBox ID="tbResult" runat="server" Text='<%#Request.QueryString["t_ID"] == null ? null : Eval("n_Result") %>'></asp:TextBox>
<asp:Label ID="lblResult" runat="server" Text='<%#Eval("Validate")%>' ForeColor="#D50000"></asp:Label>
<asp:FilteredTextBoxExtender ID="ftbe" runat="server" TargetControlID="tbResult" FilterType="Custom, Numbers" ValidChars='<%#Eval("n_Mask")%>' />
<asp:RequiredFieldValidator runat="server" ID="RReq"
ControlToValidate="tbResult"
Display="None"
ErrorMessage="A Result is required." />
<asp:ValidatorCalloutExtender runat="Server" ID="RReqE"
TargetControlID="RReq"
HighlightCssClass="validatorCalloutHighlight" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Date Completed">
<ItemTemplate>
<asp:TextBox ID="tbDate" runat="server" Text='<%#Request.QueryString["t_ID"] == null ? null : Eval("d_DateCompleted") %>'></asp:TextBox>
<asp:Image ID="imgCalendar" runat="server" ImageUrl="~/App_Themes/Sugar2006/images/Calendar_scheduleHS.png" ImageAlign="Middle" />
<asp:CalendarExtender ID="ce" runat="server" TargetControlID ="tbDate" PopupButtonID="imgCalendar" />
<asp:MaskedEditExtender ID="mex" runat="server"
TargetControlID="tbDate"
Mask="99/99/9999"
MaskType="Date"
MessageValidatorTip="true"
OnFocusCssClass="MaskedEditFocus"
OnInvalidCssClass="MaskedEditError" />
<asp:MaskedEditValidator ID="mev" runat="server"
ControlToValidate="tbDate"
ControlExtender="mex"
Display="Dynamic"
InvalidValueMessage="This date is invalid!" Font-Bold="True"
ForeColor="#D50000" />
<asp:RequiredFieldValidator runat="server" ID="DReq"
ControlToValidate="tbDate"
Display="None"
ErrorMessage="A Date is required." />
<asp:ValidatorCalloutExtender runat="Server" ID="DReqE"
TargetControlID="DReq"
HighlightCssClass="validatorCalloutHighlight" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<asp:Label ID="lblSave" runat="server" Text="**After Each Test Entry Please Save." ForeColor="#D50000"></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlResult" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
<asp:Content ID="Content1" ContentPlaceHolderID="cntSidebar" runat="server">
<asp:Button ID="btnSave" runat="server" Text="Save" Width="80%"
onclick="btnSave_Click"/> <br />
<asp:Button ID="btnClose" runat="server" Text="Close" Width="80%"
onclick="btnClose_Click" CausesValidation="false"/>
</asp:Content>
Have you tried setting the following properties on the Commit button:
CausesValidation="true" ValidationGroup="vgMyGroup"
Also, try setting the validation controls property: ValidationGroup="vgMyGroup"
Another suggestion could be to do a postback on the Commit button's click event and check for
if(Page.IsValid)...
I would be interested to see if setting the ValidationGroup property persists across the ASP content controls..
Related
In a page I have a grid and 2 drop down lists inside a update panel. From drop down list user will select and selected item will saved and shown in update panel. I am also planning to use updateprogress with it.
On doing this I am getting this design time error " 'System.Web.UI.WebControls.ImageButton' does not have a public property named 'UpdateProgress'"
I have spent a lot of time on it but couldn't solve it. Please help me. Here is my code for this.
<tr>
<td colspan="3">
<div>
<asp:Label runat="server" ID="Label1" Text="Update your professional experience below"></asp:Label>
<asp:UpdatePanel runat="server" ID="upExperience">
<ContentTemplate>
<asp:DropDownList runat="server" AutoPostBack="true" ID="ddlCategory">
</asp:DropDownList>
<asp:DropDownList runat="server" ID="ddlValues">
</asp:DropDownList>
<asp:Button runat="server" ID="btnAddNew" Text="Add New" />
<asp:GridView runat="server" ID="gvExperience" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Category" HeaderText="Category" />
<asp:BoundField DataField="Experience" HeaderText="Experience" />
<asp:BoundField DataField="Status" HeaderText="Status" />
<asp:TemplateField HeaderText="Remove">
<ItemTemplate>
<asp:ImageButton runat="server" ID="btnRemove" CommandArgument="<%#Eval("ID")%>" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress runat="server" ID="upp">
<ProgressTemplate>
<img src="../Images/loading.gif" />
</ProgressTemplate>
</asp:UpdateProgress>
</div>
</td>
</tr>
Your ImageButton server control is not well formed because of the double qoutes surroundings the Eval, so the asp:UpdateProgress is being seen as the continuation of the tag. Replace with this:
<asp:ImageButton runat="server" ID="btnRemove" CommandArgument='<%#Eval("ID")%>' />
I am using the modal pop up in the code below. I am getting the following error:
Cannot unregister UpdatePanel with ID 'updatePnl' since it was not registered with the ScriptManager. This might occur if the UpdatePanel was removed from the control tree and later added again, which is not supported.
Parameter name: updatePanel
What could be causing this?
Here is my code:
<telerik:GridTemplateColumn HeaderStyle-Width="20%" HeaderText="See Your Assessment">
<ItemTemplate>
<asp:Button CommandName="Show" OnClick="grdMasterbtnClick" CommandArgument='<%#Eval("SurveyClientID")%>'
ID="btn" runat="server" Text="Your Assessment" />
<cc1:ModalPopupExtender CancelControlID="btnCancel" PopupControlID="modelPopUp" ID="ModalPopupExtender1"
runat="server" TargetControlID="imgClientFreeEval">
</cc1:ModalPopupExtender>
<asp:UpdatePanel ID="updatePnl" runat="server">
<ContentTemplate>
<asp:Panel ID="modelPopUp" runat="server" Visible="false" BackColor="AliceBlue">
<p>
These items will be permanently deleted and cannot be recovered. Are you sure?
</p>
<asp:Button ID="btnOk" Text="OK" runat="server" />
<asp:Button ID="btnCancel" Text="Cancel" runat="server" />
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</ItemTemplate>
<HeaderStyle Width="20%"></HeaderStyle>
</telerik:GridTemplateColumn>
All respected, I have a Master detail project asp.net (sql data) project in which Master.aspx along with code behind page Master.aspx.cs. Following is the code:
<asp:TemplateField HeaderText="Date of Failure" SortExpression="Failure_date" >
<EditItemTemplate>
<asp:TextBox ID="EditFailure_date" runat="server" Text='<%# Bind("Failure_date", "{0:d}") %>' ></asp:TextBox><img src="_images/images.jpg" style="margin-top:3px;width:30px;height:30px;cursor:hand;" onclick="PopupPicker('EditFailure_date')" />
<asp:RequiredFieldValidator ID="Failure_dateRequiredFieldValidator" runat="server" ControlToValidate="EditFailure_date" Display="Dynamic" ErrorMessage="Can not be blank" SetFocusOnError="True"></asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemStyle HorizontalAlign="Left" VerticalAlign="Top" />
<HeaderStyle HorizontalAlign="Left" VerticalAlign="Top" />
<ItemTemplate>
<asp:Label ID="Failure_date" runat="server" Text='<%# Bind("Failure_date", "{0:dd/MM/yyyy}") %>' ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
Now I want to add a popup calender for above text box 'EditFailure_date' without codebehind. Please help.
You can use the AjaxControlToolkit's calendar like this:
<asp:TextBox ID="EditFailure_date" runat="server" Text='<%# Bind("Failure_date", "{0:d}") %>' ></asp:TextBox>
<ajaxToolkit:CalendarExtender runat="server" ID="cal_EditFailure_date" TargetControlID="EditFailure_date" />
Edit: You can also use a jquery solution such as the jQueryUI DatePicker
<asp:TextBox ID="txtDOJ" Text='<%# Bind("DOJ", "{0:dd-MMM-yyyy}") %>' runat="server" class="form-control input-sm m-bot15" BackColor="#cbeddc"></asp:TextBox> <asp:CalendarExtender ID="CalExtender" runat="server" Enabled="true" Format="dd-MMM-yyyy" TargetControlID="txtDOJ"> </asp:CalendarExtender>
I am facing little issue in my web application in asp.net.
i am receiving the below error :
Error: Sys.InvalidOperationException: Handler was not added through the Sys.UI.DomEvent.addHandler method.
I have used Updatepanel and this error occurs when i try to do some 2-3 actions very quickly.
and when next time i try to do take some action my web application just hungs up.
Please suggest.
Thanks
In my case this was caused by having the 'Close' control within an Update Panel in the Modal Popup. I fixed it by creating a 'dummy' button outside of the Update Panel, and setting it as the 'CancelControlID' in the MPE attributes:
<asp:Button ID="btnDummyCloseWindow" runat="server" Style="visibility: hidden"/>
<ajaxToolkit:ModalPopupExtender ID="mpeWindow" runat="server" PopupControlID="pnlWindow"
TargetControlID="btnDummyOtherButton" BackgroundCssClass="modalBackground"
DropShadow="false" CancelControlID="btnDummyCloseWindow" />
You'll need to make sure the close button that is present within your Update Panel has actions assigned to it to close the window (e.g. mpeWindow.hide()).
It's also worth noting that I was also making use of the TargetControlID 'fix' too, where a dummy button is referenced, so ignore the TargetControlID attribute there.
I've solved the problem setting ScriptMode property of ScriptManager to Release instead of Debug
By default ScriptManager is set to Debug mode.
I had the same problem and solved by placing the ModalPopupExtender or the user control that uses ModalPopupExtender inside an update panel.
Which ever way you want to look at it, the problem is inherit in what I believe is a bug in AJAX.
The only way I was able to resolve this was to control your Sorting or Paging on the server side where you control or more specifically refresh the UpdatePanel along with making sure the ModalPopup has been kept visible!
The reason for the error is really because once you do a sort of page change on a GridView that's inside an UpdatePanel, the controls have been "lost" to the UpdatePanel.
A better explanation is here.
Here is a column from my GridView...
<asp:GridView ID="gvTETstudents" runat="server" AutoGenerateColumns="False" AllowSorting="True" CellPadding="4" ForeColor="#333333" Font-Size="Small" Width="100%"
DataSourceID="sdsTETstudents"
OnRowCreated="gvTETstudents_RowCreated"
OnRowDataBound="gvTETstudents_RowDataBound"
OnDataBound="gvTETstudents_DataBound">
<Columns>
..
..
<ItemTemplate>
<asp:UpdatePanel ID="upWEF1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnWEFCLOSE" />
</Triggers>
<ContentTemplate>
...
...
<asp:Panel ID="pnlWEF2" runat="server" style="display:none;">
<table><tr><td>
<asp:Button ID="btnWEFshow" runat="server"
Text="ALL"
Font-Size="Small" Font-Names="Arial"
ToolTip="Click here to see all of this student's work experience feedback on file" />
<ajaxToolkit:ModalPopupExtender ID="mpeWEF" runat="server"
BackgroundCssClass="modalBackground"
OkControlID="btnWEFCLOSE"
PopupControlID="upWEF2"
TargetControlID="btnWEFshow">
</ajaxToolkit:ModalPopupExtender>
<asp:UpdatePanel ID="upWEF2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="pnlWEF3" runat="server" CssClass="pnlEndorsed">
<div id="Hdr" style="text-align: center">
<asp:Label ID="lblWEFHdr" runat="server">** CONTACT LOG **</asp:Label>
</div>
<div id="Bdy">
<table style="width:100%"><tr><td>
<asp:GridView ID="gvWEFContactLog" runat="server"
Font-Size="X-Small" CellPadding="4" ForeColor="#333333" GridLines="None" AllowPaging="true" PageSize="8" AllowSorting="True" AutoGenerateColumns="False" Width="100%"
DataKeyNames="StudentContactLogID,Private,ApprenticeContactLogID"
DataSourceID="sdsWEF"
OnRowDataBound="gvWEFContactLog_RowDataBound"
OnPageIndexChanging="gvWEFContactLog_PageIndexChanging"
OnSorted="gvWEFContactLog_Sorted">
<Columns>
<asp:TemplateField HeaderText="First Entered" SortExpression="FirstEntered">
<ItemTemplate>
<asp:HiddenField ID="hfWEFStudCLid" runat="server" Value='<%# Eval("StudentContactLogID") %>' />
<asp:HiddenField ID="hfWEFAppCLid" runat="server" Value='<%# Eval("ApprenticeContactLogID") %>' />
<asp:HiddenField ID="hfPrivate" runat="server" Value='<%# Eval("Private") %>' />
<asp:HiddenField ID="hfNotes" runat="server" Value='<%# Eval("ContactNotes") %>' />
<asp:LinkButton ID="lnkWEFCLOG" runat="server"
Text='<%# Eval("FirstEntered","{0:d MMM yyyy HH:mm}") %>'></asp:LinkButton>
<a id="lnkDummy" runat="server" visible=false></a>
<ajaxToolkit:ModalPopupExtender ID="mpeWEFCLOG" runat="server"
OkControlID="btnWEFCLOSEview"
PopupControlID="upWEFCLOG"
TargetControlID="lnkWEFCLOG">
</ajaxToolkit:ModalPopupExtender>
<asp:UpdatePanel ID="upWEFCLOG" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div id="pnlWEFCLOG" runat="server" class="pnlCLOG">
<asp:TextBox ID="txtWEFCLOG" runat="server"
Wrap="true"
TextMode="MultiLine"
Rows="10"
ReadOnly="true"
Width="98%">
</asp:TextBox>
<br />
<asp:Button ID="btnWEFCLOSEview" runat="server" Text="OK" Width="100%" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Subject" HeaderText="Subject" SortExpression="Subject" />
<asp:BoundField Visible="False" DataField="StudentContactLogID" HeaderText="LogID"
InsertVisible="False" ReadOnly="True" SortExpression="StudentContactLogID">
<ItemStyle HorizontalAlign="Center" />
<HeaderStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="StaffName" HeaderText="Staff" ReadOnly="True" SortExpression="StaffName" />
<asp:TemplateField HeaderText="Contact Date Time" SortExpression="ContactDateTime">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("ContactDateTime","{0:d MMM yyyy HH:mm}") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Follow-Up Date" SortExpression="FollowUpDate">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("FollowUpDate","{0:d MMM yyyy}") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Private" HeaderText="Private" SortExpression="Private" />
</Columns>
<EmptyDataTemplate>
No Current Entries
</EmptyDataTemplate>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<EditRowStyle BackColor="#999999" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
<asp:SqlDataSource ID="sdsWEF" runat="server" ConnectionString="<%$ ConnectionStrings:ATCNTV1ConnectionString %>"
SelectCommand="spTETStudentContactLogView" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:Parameter Name="StudentID" Type="string" />
<asp:Parameter Name="WEF" Type="string" DefaultValue="%" />
</SelectParameters>
</asp:SqlDataSource>
</td></tr>
<tr style="text-align: center">
<td style="text-align: left">
<asp:Button ID="btnWEFCLOSE" runat="server"
Text="CLOSE"
CausesValidation="false" Font-Bold="True" Width="61px" />
</td>
</tr>
</table>
</div>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</td></tr></table>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</ItemTemplate>
The major point of the code above is that I have a very deep GridView inside an UpdatePanel that's inside a ModalPopUp.
Now look at what I have inside that GridView:
OnPageIndexChanging
and
OnSorted
Inside the GridView, there is another ModalPopup and TextBox. Ignore that. That's only so the user can see the comments from the student's contact log as another popup window.
So if we now go to the code behind for the above two events:
protected void gvWEFContactLog_Sorted(object sender, EventArgs e)
{
GridView gvWEFCL = (GridView)sender;
GridViewRow gvRow = (GridViewRow)gvWEFCL.NamingContainer;
UpdatePanel upWEF1 = (UpdatePanel)gvRow.FindControl("upWEF1");
if (upWEF1 != null) upWEF1.Update();
AjaxControlToolkit.ModalPopupExtender mpeWEF = (AjaxControlToolkit.ModalPopupExtender)gvRow.FindControl("mpeWEF");
if (mpeWEF != null) mpeWEF.Show();
}
protected void gvWEFContactLog_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView gvWEFCL = (GridView)sender;
GridViewRow gvRow = (GridViewRow)gvWEFCL.NamingContainer;
UpdatePanel upWEF1 = (UpdatePanel)gvRow.FindControl("upWEF1");
if (upWEF1 != null) upWEF1.Update();
AjaxControlToolkit.ModalPopupExtender mpeWEF = (AjaxControlToolkit.ModalPopupExtender)gvRow.FindControl("mpeWEF");
if (mpeWEF != null) mpeWEF.Show();
}
Notice that I am not actually controlling the sorting or the paging itself. I am only forcing the GridView to call upon the main UpdatePanel (upWEF1) to refresh itself via an Update() call. The next step is to grab the ModalPopup I want to keep visible and re-Show() it!
And that's all there is to it!
I am sure there is a cleaner solution using JavaScript itself, but for me this avoids that dread meaningless error and I have a clean set of popups and update panels that can handle both hotlinks, sorting and paging as I want the GridView to perform!
I have a gridview like this :
<asp:MultiView ID="MvCustomer" runat="server" ActiveViewIndex="0" >
<%--View 1 to List the customers--%>
<asp:View ID="VwCustomersList" runat="server" >
<asp:GridView ID="GvListCustomer" runat="server" AutoGenerateColumns="False"
HorizontalAlign="Center" DataSourceID="OdsGvCustomers" DataKeyNames="CUSNUM"
EnableModelValidation="True" onrowcommand="GvListCustomer_RowCommand" >
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="LblCUSNUM" runat="server" Text='<%#Eval("CUSNUM") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="LblCO_NAM" runat="server" Text='<%#Eval("CO_NAM") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="LblCUSCTY" runat="server" Text='<%#Eval("CUSCTY") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<%--<asp:CommandField ButtonType="Button" SelectText="Edit" ShowSelectButton="true" />--%>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="BtnSelect" runat="server" Text="Edit" CommandArgument='<%#Eval("CUSNUM")%>' CommandName="Select" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="BtnDelete" runat="server" Text="Delete" CommandArgument='<%#Eval("CUSNUM")%>' CommandName="Delete" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="OdsGvCustomers" runat="server"
SelectMethod="GetAllCustomers" TypeName="MultiView_EF.BLL.Customers_BLL">
</asp:ObjectDataSource>
</asp:View>
<%--View 2 to show customer details--%>
<asp:View ID="VwCustomerDetail" runat="server" >
<asp:FormView ID="FvCustomerDetails" runat="server" HorizontalAlign="Center"
DataSourceID="OdsFvCustomerDetails" EnableModelValidation="True" DefaultMode="Edit" >
<EditItemTemplate>
CUSNUM:
<asp:TextBox ID="CUSNUMTextBox" runat="server" Text='<%# Bind("CUSNUM") %>' />
<br />
CO_NAM:
<asp:TextBox ID="CO_NAMTextBox" runat="server" Text='<%# Bind("CO_NAM") %>' />
<br />
CUSCTY:
<asp:TextBox ID="CUSCTYTextBox" runat="server" Text='<%# Bind("CUSCTY") %>' />
<br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True"
CommandName="Update" Text="Update" />
<asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
<InsertItemTemplate>
CUSNUM:
<asp:TextBox ID="CUSNUMTextBox" runat="server" Text='<%# Bind("CUSNUM") %>' />
<br />
CO_NAM:
<asp:TextBox ID="CO_NAMTextBox" runat="server" Text='<%# Bind("CO_NAM") %>' />
<br />
CUSCTY:
<asp:TextBox ID="CUSCTYTextBox" runat="server" Text='<%# Bind("CUSCTY") %>' />
<br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True"
CommandName="Insert" Text="Insert" />
<asp:LinkButton ID="InsertCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</InsertItemTemplate>
<%--<ItemTemplate>
CUSNUM:
<asp:Label ID="CUSNUMLabel" runat="server" Text='<%# Bind("CUSNUM") %>' />
<br />
CO_NAM:
<asp:Label ID="CO_NAMLabel" runat="server" Text='<%# Bind("CO_NAM") %>' />
<br />
CUSCTY:
<asp:Label ID="CUSCTYLabel" runat="server" Text='<%# Bind("CUSCTY") %>' />
<br />
</ItemTemplate>--%>
</asp:FormView>
<asp:ObjectDataSource ID="OdsFvCustomerDetails" runat="server"
SelectMethod="GetCustomerByCusnum" TypeName="MultiView_EF.BLL.Customers_BLL">
<SelectParameters>
<asp:ControlParameter ControlID="GvListCustomer" Name="cusnum"
PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
</asp:View>
</asp:MultiView>
My idea is that when the user clicks "BtnSelect" I will change the View to the view containing the FormView which has a select method configured to take the SelectedValue of the GridView as an input parameter - it will show the details of the selected customer.
I have done this before "n" number of times but I am not able to get it working this time. The trouble is that when the call for the Select Method of the formview goes to the relevant function - "GetCustomerByCusnum" I have a null value in its parameter "cusnum".
I know that I can write a selecting event and using CommandArgument, parse the value of the selected row and pass it into the Select method as a value but I dont want that solution. I know it works without the "Selecting" method but I cant recall how.
Please help.
By looking at your code, all seems ok, just a single hint, if you are not setting the active view, do it by SetActiveView method of multiview, please do that in button click.
Another thing you can do is: add OdsFvCustomerDetails_Selecting and OdsFvCustomerDetails_Selected events. in Selecting you can see the params and values passed and in Selected you can see e.Exception if there is any error in the query. so it will give you more idea about what exactly is going wrong.
Additional note
Another thing that should be noted is, multivew control works in a way that it binds all the views regardless of whichever is active so it degrades the performance. You may probably find better idea
Yikes. A relic of a question - IIRC I did away with the MV approach for this as we moved list and details section to different aspx pages and used query string parameters. Never got to fix what must have been, in hindsight, some missing parameter assignment.