I'm able to create a new user but fail to add a role to the created user
Here my cs code :
to generate role into the dropdownlist
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
CreateUserWizard CreateUserWizard1 = (CreateUserWizard)LoginView1.FindControl("CreateUserWizard1");
DropDownList role = (DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("role");
if(role!=null)
{
string[] allRoles = Roles.GetAllRoles();
foreach (string roles in allRoles)
{
role.Items.Add(new ListItem(roles));
}
}
}
}
to insert role into username
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
CreateUserWizard CreateUserWizard1 = (CreateUserWizard)LoginView1.FindControl("CreateUserWizard1");
DropDownList role = (DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("role");
Roles.AddUserToRole(CreateUserWizard1.UserName, role.SelectedValue);
}
ASPX Code:
createuserwizard in loginview
<asp:LoginView ID="LoginView1" runat="server">
<RoleGroups>
<asp:RoleGroup Roles="System Admin">
<ContentTemplate>
<asp:CreateUserWizard ID="CreateUserWizard1" runat="server" BackColor="#F7F6F3"
BorderColor="#E6E2D8" BorderStyle="Solid" BorderWidth="1px"
Font-Names="Verdana" Font-Size="0.8em"
ContinueDestinationPageUrl="~/Default.aspx">
<SideBarStyle BackColor="#5D7B9D" BorderWidth="0px" Font-Size="0.9em"
VerticalAlign="Top" />
<SideBarButtonStyle BorderWidth="0px" Font-Names="Verdana" ForeColor="White" />
<ContinueButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC"
BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana"
ForeColor="#284775" />
<NavigationButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC"
BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana"
ForeColor="#284775" />
<HeaderStyle BackColor="#5D7B9D" BorderStyle="Solid" Font-Bold="True"
Font-Size="0.9em" ForeColor="White" HorizontalAlign="Center" />
<CreateUserButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC"
BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana"
ForeColor="#284775" />
<TitleTextStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<StepStyle BorderWidth="0px" />
<WizardSteps>
<asp:CreateUserWizardStep runat="server">
<ContentTemplate>
<table border="0" style="font-family:Verdana;font-size:100%;">
<tr>
<td align="center" colspan="2"
style="color:White;background-color:#5D7B9D;font-weight:bold;">
Sign Up for Your New Account</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User
Name:</asp:Label>
</td>
<td>
<asp:TextBox ID="UserName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server"
ControlToValidate="UserName" ErrorMessage="User Name is required."
ToolTip="User Name is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
</td>
<td>
<asp:TextBox ID="Password" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server"
ControlToValidate="Password" ErrorMessage="Password is required."
ToolTip="Password is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="ConfirmPasswordLabel" runat="server"
AssociatedControlID="ConfirmPassword">Confirm Password:</asp:Label>
</td>
<td>
<asp:TextBox ID="ConfirmPassword" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="ConfirmPasswordRequired" runat="server"
ControlToValidate="ConfirmPassword"
ErrorMessage="Confirm Password is required."
ToolTip="Confirm Password is required."
ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email">E-mail:</asp:Label>
</td>
<td>
<asp:TextBox ID="Email" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="EmailRequired" runat="server"
ControlToValidate="Email" ErrorMessage="E-mail is required."
ToolTip="E-mail is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="Label1" runat="server" Text="Role :"></asp:Label>
</td>
<td>
<asp:DropDownList ID="role" runat="server" AutoPostBack="True" >
</asp:DropDownList>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="QuestionLabel" runat="server" AssociatedControlID="Question">Security
Question:</asp:Label>
</td>
<td>
<asp:TextBox ID="Question" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="QuestionRequired" runat="server"
ControlToValidate="Question" ErrorMessage="Security question is required."
ToolTip="Security question is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="AnswerLabel" runat="server" AssociatedControlID="Answer">Security
Answer:</asp:Label>
</td>
<td>
<asp:TextBox ID="Answer" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="AnswerRequired" runat="server"
ControlToValidate="Answer" ErrorMessage="Security answer is required."
ToolTip="Security answer is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<asp:CompareValidator ID="PasswordCompare" runat="server"
ControlToCompare="Password" ControlToValidate="ConfirmPassword"
Display="Dynamic"
ErrorMessage="The Password and Confirmation Password must match."
ValidationGroup="CreateUserWizard1"></asp:CompareValidator>
</td>
</tr>
<tr>
<td align="center" colspan="2" style="color:Red;">
<asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal>
</td>
</tr>
</table>
</ContentTemplate>
</asp:CreateUserWizardStep>
<asp:CompleteWizardStep runat="server" >
<ContentTemplate>
<table border="0" style="font-family:Verdana;font-size:100%;">
<tr>
<td align="center" colspan="2"
style="color:White;background-color:#5D7B9D;font-weight:bold;">
Complete</td>
</tr>
<tr>
<td>
Your account has been successfully created.</td>
</tr>
<tr>
<td align="right" colspan="2">
<asp:Button ID="ContinueButton" runat="server" BackColor="#FFFBFF"
BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px"
CausesValidation="False" CommandName="Continue" Font-Names="Verdana"
ForeColor="#284775" Text="Continue" ValidationGroup="CreateUserWizard1" />
</td>
</tr>
</table>
</ContentTemplate>
</asp:CompleteWizardStep>
</WizardSteps>
</asp:CreateUserWizard>
</ContentTemplate>
</asp:RoleGroup>
</RoleGroups>
<AnonymousTemplate>
Access Denied.
</AnonymousTemplate>
</asp:LoginView>
Can anyone help me to find and fix my error?
Problem solved ^^ after I added
oncreateduser="CreateUserWizard1_CreatedUser"
inside CreateUserWizard tag
Related
I am new to ASP.NET. I have taken a Panel. Inside the Panel, I have taken a table. Inside the table there are TextBox, RadioButton and a Button controls.
I have written some code in button_click event.
But nothing happens. button_click event is not firing.
What to do now ?
I have also some other things in panel. But no click event is working.
Code is below:
<asp:Panel ID="Pnlproducts" runat="server" ScrollBars="Auto" Height="500px" BorderColor="Black" BorderStyle="Inset" BorderWidth="1px">
<asp:DataList ID="DLProducts" runat="server" RepeatColumns="3" Width="600px" OnSelectedIndexChanged="DLProducts_SelectedIndexChanged">
<ItemTemplate >
<table align="left" class="auto-style6" style="border-color:#9900FF;border-left:1px;border-right:1px;border-top:1px;">
<tr>
<td style="border-color: #000000; border-width: 1px; border-bottom-style: ridge" class="auto-style8">
<asp:Label ID="lblProductName" runat="server" Text="<%# Bind('ProductName') %>" Font-Bold="True"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style9">
<asp:Image ID="Image2" runat="server" Height="160px" ImageUrl="<%# Bind('ProductImage') %>" Width="173px" Style="border:ridge 1px black" />
</td>
</tr>
<tr>
<td class="auto-style9"><strong>Price:</strong><asp:Label ID="lblPrice" runat="server" Text="<%# Bind('ProductPrice') %>" Font-Bold="True" ForeColor="Red"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style9">
<asp:Button ID="Addtocartbtn" runat="server" BorderStyle="Solid" BorderWidth="1px" OnClick="Addtocartbtn_Click" Text="Add to Cart" Width="170px" BorderColor="Black" />
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</asp:Panel>
<asp:Panel ID="Panel111" runat="server" ScrollBars="Auto" Height="500px" BorderColor="Black" BorderStyle="Inset" BorderWidth="1px">
<table class="auto-style16">
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
</asp:Panel>
</td>
<td>
<asp:Panel ID="pnlCatagory" runat="server" Height="500px" ScrollBars="Auto" BorderColor="Black" BorderStyle="Inset" BorderWidth="1px">
<div class="auto-style7">
<asp:DataList ID="dlCatagory" runat="server" BackColor="White" BorderColor="#CCCCCC" BorderWidth="1px" CellPadding="4" ForeColor="Black" GridLines="Horizontal">
<FooterStyle BackColor="#CCCC99" ForeColor="Black" />
<HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
<ItemTemplate>
<asp:LinkButton ID="LBTNCatagoty" runat="server" CommandArgument="<%# Bind('CatagoryID') %>" Font-Bold="True" OnClick="LBTNCatagoty_Click" Text="<%# Bind('CatagoryName') %>"></asp:LinkButton>
</ItemTemplate>
</asp:DataList>
</div>
</asp:Panel>
<asp:Panel ID="Panel222" runat="server" Height="500px" ScrollBars="Auto" BorderColor="Black" BorderStyle="Inset" BorderWidth="1px">
<table class="auto-style10">
<tr>
<td class="auto-style7" colspan="2"><strong>Please Type Your Details</strong></td>
</tr>
<tr>
<td class="auto-style12"></td>
<td class="auto-style11"></td>
</tr>
<tr>
<td class="auto-style15">Name :</td>
<td class="johnykbd8">
<asp:TextBox ID="TextBoxUserName" runat="server" Width="180px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style15">E-mail :</td>
<td class="johnykbd8">
<asp:TextBox ID="TextBoxEmail" runat="server" Width="180px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style15">Address:</td>
<td class="johnykbd8">
<asp:TextBox ID="TextBoxAdress" runat="server" Height="90px" TextMode="MultiLine" Width="180px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style15">Gender :</td>
<td>
<asp:RadioButton ID="RadioButton1" runat="server" GroupName="GenderGroup" Text="Male" /><br />
<asp:RadioButton ID="RadioButton2" runat="server" GroupName="GenderGroup" Text="Female" />
</td>
</tr>
<tr>
<td class="auto-style15">Mobile:</td>
<td class="johnykbd8">
<asp:TextBox ID="TextBoxMobileNum" runat="server" Width="180px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style15">Photo :</td>
<td class="johnykbd8">
<asp:FileUpload ID="FileUploaduserphoto" runat="server" Width="180px" />
</td>
</tr>
<tr>
<td class="auto-style15">Payment :</td>
<td>
<asp:RadioButton ID="RadioButton3" runat="server" GroupName="Paymentgroup" Text="Visa" /><br />
<asp:RadioButton ID="RadioButton4" runat="server" GroupName="Paymentgroup" Text="MasterCard" /><br />
<asp:RadioButton ID="RadioButton5" runat="server" GroupName="Paymentgroup" Text="Cash On Delivery" />
</td>
</tr>
<tr>
<td class="auto-style15">Review :</td>
<td>
<asp:TextBox ID="TextBoxreview" runat="server" Width="180px"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style15">Total : </td>
<td>BDT :<asp:Label ID="Labelshopamount" runat="server"></asp:Label></td>
</tr>
<tr>
<td colspan="2">
<asp:ImageButton ID="ImageButtonOrderNow" runat="server" ImageUrl="~/Images/Designing/order.jpg" OnClick="ImageButtonOrderNow_Click" Width="250px" />
</td>
</tr>
</table>
</asp:Panel>
If the button is in a datalist or gridview for example, set the CommandName property. The databound object (datalist, gridview) has ItemCommand-event. Put the code in this event.
Pseudo code:
if (e.CommandName.equals(your_command_name)){ label1.text = e.CommandArgument };
Hi can anyone help me with this. I am using dynamic data and have created a custom page which displays all orders within a database table. Once someone selects an order I would like it display all the individual items for that order. This data is stored in another table but within the same database. I found a very useful article on here Asp.net Dynamic data multiple relational entities on single page which I think gives me pretty much my answer but I am stuck where it comes to the part about implementing IEnumerable (I am trying to implement version 2 on the page). I have done some reading on IEnumerable but I am really lost. I'm not sure if I'm supposed to create a new class. Can anyone help?
Here is the code I have so far:
HTML code:
<h2 class="DDSubHeader">Catering Request Orders</h2>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div class="DD">
<asp:ValidationSummary ID="ValidationSummary1" runat="server" EnableClientScript="true"
HeaderText="List of validation errors" CssClass="DDValidator" />
<asp:DynamicValidator runat="server" ID="GridViewValidator" ControlToValidate="GridView1" Display="None" CssClass="DDValidator" />
<asp:DynamicValidator runat="server" ID="FormViewValidator" ControlToValidate="FormView1" Display="None" CssClass="DDValidator" />
<asp:QueryableFilterRepeater runat="server" ID="FilterRepeater">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("DisplayName") %>' OnPreRender="Label_PreRender" />
<asp:DynamicFilter runat="server" ID="DynamicFilter" OnFilterChanged="DynamicFilter_FilterChanged" /><br />
</ItemTemplate>
</asp:QueryableFilterRepeater>
<br />
<asp:Button ID="searchButton" runat="server" Text="Search" OnClick="SearchButton_Click" />
</div>
<asp:GridView ID="GridView1" runat="server" DataSourceID="GridDataSource" EnablePersistedSelection="True"
AutoGenerateSelectButton="True"
AutoGenerateColumns="False"
AllowPaging="True" AllowSorting="True" OnDataBound="GridView1_DataBound"
OnRowEditing="GridView1_RowEditing" OnSelectedIndexChanging="GridView1_SelectedIndexChanging"
OnRowDeleted="GridView1_RowDeleted" OnRowUpdated="GridView1_RowUpdated"
OnRowCreated="GridView1_RowCreated" CssClass="DDGridView"
RowStyle-CssClass="td" HeaderStyle-CssClass="th" CellPadding="6">
<Columns>
<%--<asp:TemplateField>
<ItemTemplate>
<asp:DynamicHyperLink ID="DynamicHyperLink1" runat="server" Text="Details" />
<a id="CategoryRouteID" runat="server" href= '<%# GetRouteInformation() %>'/>
<%-- <asp:DynamicHyperLink ID="DynamicHyperLink1" runat="server" Text="Details" />
<!-- Create action link to filter items that
belong to the same category -->
<a ID="CategoryRouteID" runat="server" href='<%# GetRouteInformation() %>'>
</a></asp:DynamicHyperLink>
</ItemTemplate>
</asp:TemplateField>--%>
<asp:DynamicField DataField="OrderNo" HeaderText="Order No" />
<asp:DynamicField DataField="DisplayName" HeaderText="Display name" />
<asp:DynamicField DataField="EmailAddress" HeaderText="Email address" />
<asp:DynamicField DataField="DeliveryDate" HeaderText="Delivery date" />
<asp:DynamicField DataField="Time" HeaderText="Time" />
<asp:DynamicField DataField="Location" HeaderText="Location" />
<asp:DynamicField DataField="Site" HeaderText="Site" />
<asp:DynamicField DataField="OrderProgress" HeaderText="Order progress" />
<asp:DynamicField DataField="tblCateringOrdersDetailsItems" HeaderText="Item details" />
</Columns>
<HeaderStyle CssClass="th" />
<PagerStyle CssClass="DDFooter" />
<RowStyle CssClass="td" />
<SelectedRowStyle CssClass="DDSelected" />
<PagerTemplate>
<asp:GridViewPager ID="GridViewPager1" runat="server" />
</PagerTemplate>
<EmptyDataTemplate>
There are currently no items in this table.
</EmptyDataTemplate>
<SortedAscendingHeaderStyle BackColor="#DEDFF0" Font-Bold="True" />
<SortedDescendingHeaderStyle BackColor="#DEDFF0" Font-Bold="True" />
</asp:GridView>
<asp:EntityDataSource ID="GridDataSource" runat="server" EnableDelete="true" EnableUpdate="true" />
<asp:QueryExtender ID="GridQueryExtender" TargetControlID="GridDataSource" runat="server">
<asp:DynamicFilterExpression ControlID="FilterRepeater" />
</asp:QueryExtender>
<asp:Panel ID="DetailsPanel" runat="server">
<br /><br />
<asp:FormView ID="FormView1" runat="server" DataSourceID="DetailsDataSource" RenderOuterTable="false"
OnPreRender="FormView1_PreRender" OnModeChanging="FormView1_ModeChanging" OnItemUpdated="FormView1_ItemUpdated"
OnItemInserted="FormView1_ItemInserted" OnItemDeleted="FormView1_ItemDeleted" OnItemCommand="FormView1_ItemCommand">
<HeaderTemplate>
<table id="detailsTable" class="DDDetailsTable" cellpadding="6">
</HeaderTemplate>
<ItemTemplate>
<tr class="td">
<td class="DDLightHeader">Order No</td>
<td><asp:DynamicControl ID="OrderNo" runat="server" DataField="OrderNo" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">User ID</td>
<td><asp:DynamicControl runat="server" DataField="UserID" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Display Name</td>
<td><asp:DynamicControl runat="server" DataField="DisplayName" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Email Address</td>
<td><asp:DynamicControl ID="EmailAddress" runat="server" DataField="EmailAddress" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Project Code</td>
<td><asp:DynamicControl runat="server" DataField="ProjectCode" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Event Description</td>
<td><asp:DynamicControl runat="server" DataField="EventDesc" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Delivery Date</td>
<td><asp:DynamicControl runat="server" DataField="DeliveryDate" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Date Ordered</td>
<td><asp:DynamicControl runat="server" DataField="DateOrdered" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Site</td>
<td><asp:DynamicControl runat="server" DataField="Site" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Time</td>
<td><asp:DynamicControl runat="server" DataField="Time" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Location</td>
<td><asp:DynamicControl runat="server" DataField="Location" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Additional Information</td>
<td><asp:DynamicControl runat="server" ID="AdditionalInfo" DataField="AdditionalInfo" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Item Costs</td>
<td><asp:DynamicControl runat="server" ID="ItemCosts" DataField="ItemCosts" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">AdditionalCosts</td>
<td><asp:DynamicControl runat="server" ID="AdditionalCosts" DataField="AdditionalCosts" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Total Costs</td>
<td><asp:DynamicControl runat="server" DataField="TotalCosts" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">More Information Required</td>
<td><asp:DynamicControl runat="server" DataField="MoreInformationRequired" UIHint="MultilineText" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Reason Rejected</td>
<td><asp:DynamicControl runat="server" DataField="ReasonRejected" UIHint="MultilineText" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Order Progress</td>
<td><asp:DynamicControl runat="server" DataField="OrderProgress" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Imported Into Dream</td>
<td><asp:DynamicControl runat="server" DataField="ImportedIntoDream" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">View Items</td>
<td><asp:DynamicControl runat="server" DataField="tblCateringOrdersDetailsItems" /></td>
</tr>
<%--<asp:DynamicEntity ID="DynamicEntity1" runat="server" />--%>
<tr class="td">
<td colspan="2">
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="Edit" Text="Edit" />
<asp:LinkButton ID="LinkButton2" runat="server" CommandName="Delete" Text="Delete"
OnClientClick='return confirm("Are you sure you want to delete this item?");' />
<%-- <asp:LinkButton ID="LinkButton3" runat="server" CommandName="New" Text="New" />--%>
</td>
</tr>
</ItemTemplate>
<EditItemTemplate>
<tr class="td">
<td class="DDLightHeader">Order No</td>
<td><asp:DynamicControl ID="OrderNo" runat="server" DataField="OrderNo" Mode="ReadOnly"/></td>
</tr>
<tr class="td">
<td class="DDLightHeader">User ID</td>
<td><asp:DynamicControl runat="server" DataField="UserID" Mode="ReadOnly"/></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Display Name</td>
<td><asp:DynamicControl runat="server" DataField="DisplayName" Mode="ReadOnly" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Email Address</td>
<td><asp:DynamicControl runat="server" DataField="EmailAddress" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Project Code</td>
<td><asp:DynamicControl runat="server" DataField="ProjectCode" Mode="ReadOnly" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Event Description</td>
<td><asp:DynamicControl runat="server" DataField="EventDesc" Mode="ReadOnly" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Delivery Date</td>
<td><asp:DynamicControl runat="server" DataField="DeliveryDate" Mode="ReadOnly" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Date Ordered</td>
<td><asp:DynamicControl runat="server" DataField="DateOrdered" Mode="ReadOnly" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Site</td>
<td><asp:DynamicControl runat="server" DataField="Site" Mode="ReadOnly" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Time</td>
<td><asp:DynamicControl runat="server" DataField="Time" Mode="ReadOnly" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Location</td>
<td><asp:DynamicControl runat="server" DataField="Location" Mode="ReadOnly" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Additional Information</td>
<td><asp:DynamicControl runat="server" DataField="AdditionalInfo" Mode="ReadOnly" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Item Costs</td>
<td><asp:DynamicControl runat="server" ID="ItemCosts" DataField="ItemCosts" Mode="Edit" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Additional Costs</td>
<td><asp:DynamicControl runat="server" ID="AdditionalCosts" DataField="AdditionalCosts" Mode="Edit" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Total Costs</td>
<td><asp:DynamicControl runat="server" ID="TotalCosts" DataField="TotalCosts" Mode="Edit" /></td>
<%--<td><asp:Button runat="server" ID="btnCalculateTotalCosts" Text="Calculate total costs" CommandName="Calculate" /></td>--%>
<%-- <asp:Button ID="btnUpdateOrder" runat="server" onclick="btnUpdateOrder_Click"
Text="Update Order" />--%>
</tr>
<tr class="td">
<td class="DDLightHeader">More Information Required</td>
<td><asp:DynamicControl runat="server" DataField="MoreInformationRequired" Mode="Edit" UIHint="MultilineText" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Reason Rejected</td>
<td><asp:DynamicControl runat="server" DataField="ReasonRejected" Mode="Edit" UIHint="MultilineText" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Order Progress</td>
<td><asp:DynamicControl runat="server" DataField="OrderProgress" Mode="Edit" UIHint="OrderProgressDropDown" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">Imported Into Dream</td>
<td><asp:DynamicControl runat="server" DataField="ImportedIntoDream" Mode="Edit" /></td>
</tr>
<tr class="td">
<td class="DDLightHeader">View Items</td>
<td><asp:DynamicControl runat="server" DataField="tblCateringOrdersDetailsItems" Mode="Edit" /></td>
</tr>
<%--<asp:DynamicEntity ID="DynamicEntity2" runat="server" Mode="Edit" />--%>
<tr class="td">
<td colspan="2">
<asp:LinkButton ID="LinkButton4" runat="server" CommandName="Update" Text="Update" />
<asp:LinkButton ID="LinkButton5" runat="server" CommandName="Cancel" Text="Cancel" CausesValidation="false" />
</td>
</tr>
</EditItemTemplate>
<InsertItemTemplate>
<asp:DynamicEntity ID="DynamicEntity3" runat="server" Mode="Insert" />
<tr class="td">
<td colspan="2">
<asp:LinkButton ID="LinkButton6" runat="server" CommandName="Insert" Text="Insert" />
<asp:LinkButton ID="LinkButton7" runat="server" CommandName="Cancel" Text="Cancel" CausesValidation="false" />
</td>
</tr>
</InsertItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:FormView>
<asp:EntityDataSource ID="DetailsDataSource" runat="server" EnableDelete="true" EnableInsert="true" EnableUpdate="true" />
<asp:QueryExtender ID="QueryExtender1" TargetControlID="DetailsDataSource" runat="server">
<asp:ControlFilterExpression ControlID="GridView1" />
</asp:QueryExtender>
</asp:Panel>
<%--code for details items --%>
<asp:Panel runat="server" ID="PanelItemDetails">
<asp:GridView ID="GridView2" runat="server"
DataSourceID="EntityDataSourceItemDetails" EnablePersistedSelection="True"
DataKeyNames="OrderNo"
AutoGenerateSelectButton="True"
AutoGenerateColumns="False"
AllowPaging="True" AllowSorting="True" OnDataBound="GridView2_DataBound"
OnRowEditing="GridView2_RowEditing" OnSelectedIndexChanging="GridView2_SelectedIndexChanging"
OnRowDeleted="GridView2_RowDeleted" OnRowUpdated="GridView2_RowUpdated"
OnRowCreated="GridView2_RowCreated" CssClass="DDGridView"
RowStyle-CssClass="td" HeaderStyle-CssClass="th" CellPadding="6">
<Columns>
<%--<asp:DynamicField DataField="tblCateringItemsDetail" HeaderText="Item" />--%>
<asp:BoundField DataField="Description" HeaderText="Description"
ReadOnly="True" SortExpression="Description" />
<asp:BoundField DataField="Quantity" HeaderText="Quantity" ReadOnly="True"
SortExpression="Quantity" />
<asp:BoundField DataField="TotalUnitCost" HeaderText="TotalUnitCost"
ReadOnly="True" SortExpression="TotalUnitCost" />
<asp:BoundField DataField="OrderNo" HeaderText="OrderNo" ReadOnly="True"
SortExpression="OrderNo" />
</Columns>
<HeaderStyle CssClass="th" />
<PagerStyle CssClass="DDFooter" />
<RowStyle CssClass="td" />
<SelectedRowStyle CssClass="DDSelected" />
<PagerTemplate>
<asp:GridViewPager ID="GridViewPager1" runat="server" />
</PagerTemplate>
<EmptyDataTemplate>
There are currently no items in this table.
</EmptyDataTemplate>
<SortedAscendingHeaderStyle BackColor="#DEDFF0" Font-Bold="True" />
<SortedDescendingHeaderStyle BackColor="#DEDFF0" Font-Bold="True" />
</asp:GridView>
<asp:QueryExtender ID="QueryExtender2" TargetControlID="EntityDataSourceItemDetails" runat="server">
<asp:CustomExpression
OnQuerying="OrdersQueryExtender_Querying" />
</asp:QueryExtender>
<asp:EntityDataSource ID="EntityDataSourceItemDetails" runat="server"
ConnectionString="name=cateringEntities"
DefaultContainerName="cateringEntities" EnableFlattening="False"
EntitySetName="vCateringOrdersAllDetails"
Select="it.[Description], it.[Quantity], it.[TotalUnitCost], it.[OrderNo]" ORDERBY="it.OrderNo]" >
</asp:EntityDataSource>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
C# code:
protected void SelectOrder_Selected(object sender, EntityDataSourceSelectedEventArgs e)
{
IEnumerable<OrderItems> orderItem = e.Results.Cast<Order>();
foreach (Order o in orderItem)
{
customerId = c.Customer_Id;
}
}
protected void OrderQueryExtender_Querying(object sender, system.Web.UI.WebControls.Expressions.CustomExpressionEventArgs e)
{
e.Query = (from a in e.Query.Cast<Order>()
where a.OrderNo == orderNo
select a);
}
Any help would be greatly appreciated.
Claire
My approach is as follows
First I display list of all orders selected in a grid view.
When user selects to see detail of any order i fire grid view row command event and pass order id as command argument.
Then in code behind i get order entity with the help of order id passed in step 2 and along with order entity i get order details and display it in second grid view.
Thank you Nimit for your response. It was very useful. If it helps anyone else I found exactly what I was looking for at http://www.asp.net/web-forms/tutorials/getting-started-with-ef/the-entity-framework-and-aspnet-getting-started-part-4.
In my project there are number of page inheriting the same masterpage and all are responding except 1 or 2 page, there is no change in code every thing is right.
I inserted breakpoint on button click button no effect.
How can i check the Problem.
Please help
Here is the code of my page
<%# Page Title="Product Stock" Language="C#" MasterPageFile="~/admin/AdminMaster.master" AutoEventWireup="true" CodeFile="ProductStock.aspx.cs" Inherits="admin_ProductStock" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">
.auto-style3 {
width: 259px;
}
.auto-style4 {
width: 479px;
}
.auto-style5 {
height: 65px;
}
.auto-style6 {
width: 479px;
height: 65px;
}
.auto-style7 {
height: 74px;
}
.auto-style8 {
width: 479px;
height: 74px;
}
.auto-style9 {
width: 69px;
}
.auto-style10 {
height: 74px;
width: 68px;
}
.auto-style11 {
height: 65px;
width: 68px;
}
.auto-style12 {
width: 68px;
}
.auto-style13 {
width: 451px;
}
.auto-style14 {
width: 451px;
height: 74px;
}
.auto-style15 {
width: 451px;
height: 65px;
}
</style>
</asp:Content>
<asp:Content ID="Content2" runat="server" contentplaceholderid="ContentPlaceHolder1">
<table style="width:100%;">
<tr>
<td>
<asp:Image ID="Image1" runat="server" Height="123px" ImageUrl="~/admin/images/insert.jpg" Width="158px" />
</td>
<td class="auto-style4">
<asp:Label ID="lblinsertion" runat="server" BackColor="#FFFF66" Font-Bold="True" Font-Italic="True" Font-Names="Euphemia" Font-Size="XX-Large" Font-Underline="True" ForeColor="#009900" Text="Insert Product Stock Information"></asp:Label>
</td>
<td class="auto-style12"> </td>
</tr>
<tr>
<td class="auto-style5">
<asp:Label ID="lblproductname" runat="server" Text="Product Name" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label>
</td>
<td class="auto-style6">
<asp:DropDownList ID="ddlprdctname" runat="server" Width="235px" ValidationGroup="vg1"></asp:DropDownList>
</td>
<td class="auto-style11">
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="ddlprdctname" ErrorMessage="Select Product Name" ValidationGroup="vg1"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblquantity" runat="server" Text="Quantity" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label>
</td>
<td class="auto-style4">
<asp:TextBox ID="txtquantity" runat="server" Width="235px" ValidationGroup="vg1"></asp:TextBox>
</td>
<td class="auto-style12">
<asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ControlToValidate="txtquantity" ErrorMessage="Enter Quantity" ValidationGroup="vg1"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblstocktype" runat="server" Text="Stock Type" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label>
</td>
<td class="auto-style4">
<asp:DropDownList ID="ddlstocktype" runat="server" Width="235px" Height="42px" ValidationGroup="vg1"></asp:DropDownList>
</td>
<td class="auto-style12">
<asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" ControlToValidate="ddlstocktype" ErrorMessage="Please Enter Stock Type" ValidationGroup="vg1"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblstockdate" runat="server" Text="Stock Date" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label>
</td>
<td class="auto-style4">
<asp:TextBox ID="txtstockdate" runat="server" ValidationGroup="vg1" Height="55px" Width="235px"></asp:TextBox>
</td>
<td class="auto-style12">
<asp:Label ID="lbldateformat" runat="server" Text="dd/mm/yy"></asp:Label>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtstockdate" ErrorMessage="Please Enter Stock Date" ValidationGroup="vg1"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style3"></td>
<td class="auto-style4">
<asp:Button ID="btnInsert" runat="server" Text="Insert" Width="125px" ValidationGroup="vg1" OnClick="btnInsert_Click" />
</td>
<td>
<asp:Button ID="check" runat="server" Text="Lets Check" />
</td>
<td class="auto-style12"> </td>
</tr>
<tr>
<td colspan="3">
<asp:Label ID="lblmsg" runat="server" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label>
</td>
</tr>
</table>
</asp:Content>
<asp:Content ID="Content3" runat="server" contentplaceholderid="ContentPlaceHolder2">
<asp:Panel ID="ViewPanel" runat="server">
<table style="width:100%;">
<tr>
<td class="auto-style3">
<asp:Image ID="Image2" runat="server" Height="100px" ImageUrl="~/admin/images/view.jpg" Width="133px" />
</td>
<td>
<asp:Label ID="Label1" runat="server" BackColor="Yellow" Font-Bold="True" Font-Italic="True" Font-Names="Euphemia" Font-Size="XX-Large" Font-Underline="True" ForeColor="#009900" Text="View All Information"></asp:Label>
</td>
<td> </td>
</tr>
</table>
<asp:GridView ID="gridview" AutoGenerateColumns="false" runat="server" style="margin-left: 0px" AllowPaging="True" AllowSorting="True" CellPadding="3" Height="238px" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="Solid" BorderWidth="1px" CellSpacing="2" OnRowCommand="gridview_RowCommand" OnPageIndexChanging="gridview_PageIndexChanging">
<Columns>
<asp:BoundField HeaderText="Stock ID" DataField="StockID" />
<asp:BoundField HeaderText="Product Name" DataField="ProductID" />
<asp:BoundField HeaderText="Quantity" DataField="Quantity" />
<asp:BoundField HeaderText="Stock Type" DataField="StockType" />
<asp:BoundField HeaderText="Stock Date" DataField="StockDate" />
<asp:TemplateField HeaderText="Delete Record">
<ItemTemplate>
<asp:Button ID="delete" OnClientClick="return confirm('Are You Sure To Delete The Record?')" Text="Delete This Record" CommandName="del" CommandArgument='<%# Eval("StockID") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Edit Record">
<ItemTemplate>
<asp:Button ID="update" CommandName="upd" Text="Edit this Record" CommandArgument='<%# Eval("StockID") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#FFF1D4" />
<SortedAscendingHeaderStyle BackColor="#B95C30" />
<SortedDescendingCellStyle BackColor="#F1E5CE" />
<SortedDescendingHeaderStyle BackColor="#93451F" />
</asp:GridView>
<asp:Label ID="lblMessage" runat="server" Text=""></asp:Label>
</asp:Panel>
<br />
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="ContentPlaceHolder3" Runat="Server">
<asp:Label ID="lblupdate" runat="server" Text="Select the record to be updated" Font-Names="Segoe Print" Font-Size=20></asp:Label>
<asp:Panel ID="UpdatePanel" runat="server">
<table style="width:100%;">
<tr>
<td>
<asp:Image ID="Image3" runat="server" Height="123px" ImageUrl="~/admin/images/insert.jpg" Width="158px" />
</td>
<td >
<asp:Label ID="lblupdupdation" runat="server" BackColor="#FFFF66" Font-Bold="True" Font-Italic="True" Font-Names="Euphemia" Font-Size="XX-Large" Font-Underline="True" ForeColor="#009900" Text="Update Product Stock Information"></asp:Label>
</td>
<td > </td>
</tr>
<tr>
<td>
<asp:Label ID="lblupdstockid" runat="server" Text="Quantity" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtupdstockid" runat="server" ReadOnly="true" Width="235px"></asp:TextBox>
</td>
</tr>
<tr>
<td >
<asp:Label ID="lblupdproductname" runat="server" Text="Product Name" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label>
</td>
<td >
<asp:DropDownList ID="ddlupdprdctname" runat="server" Width="235px"></asp:DropDownList>
</td>
<td >
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="ddlupdprdctname" ErrorMessage="Enter Product Name"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblupdquantity" runat="server" Text="Quantity" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtupdquantity" runat="server" Width="235px"></asp:TextBox>
</td>
<td >
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtupdquantity" ErrorMessage="Enter Quantity"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblupdstocktype" runat="server" Text="Stock Type" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label>
</td>
<td >
<asp:DropDownList ID="ddlupdstocktype" runat="server" Width="235px"></asp:DropDownList>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="ddlupdstocktype" ErrorMessage="Please Enter Stock Type"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblupdstockdate" runat="server" Text="Stock Date" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtupdstockdate" runat="server" ValidationGroup="vg1" Height="16px" Width="235px"></asp:TextBox>
</td>
<td >
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtupdstockdate" ErrorMessage="Please Enter Stock Date" ValidationGroup="vg1"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td></td>
<td >
<asp:Button ID="btnUpdate" runat="server" Text="Update" Width="125px" ValidationGroup="vg1" OnClick="btnUpdate_Click" />
</td>
<td > </td>
</tr>
<tr>
<td colspan="3">
<asp:Label ID="lblupdmsg" runat="server" Font-Bold="True" Font-Italic="True" Font-Size="Medium"></asp:Label>
</td>
</tr>
</table>
</asp:Panel>
</asp:Content>
My Client side code for button
protected void btnInsert_Click(object sender, EventArgs e)
{
try
{
int productID, quantity;
string stockType;
DateTime stockDate;
productID = int.Parse(ddlprdctname.SelectedValue);
quantity = int.Parse(txtquantity.Text.Trim());
stockType = ddlstocktype.SelectedValue.ToString().Trim();
stockDate = DateTime.Parse(txtstockdate.Text.Trim());
ProductStock prdctstock = new ProductStock();
prdctstock.ProductID = productID;
prdctstock.Quantity = quantity;
prdctstock.StockType = stockType;
prdctstock.StockDate = stockDate;
if (new InsertAction().InsertData(prdctstock))
{
lblmsg.Text = "Inserted Sucessfully";
ViewPanel.Visible = true;
}
else
{
lblmsg.Text = "Please Check all the fields";
}
BindGridView();
ProductInfo prdctinfo = new ProductInfo();
if (stockType == "In")
{
prdctinfo.Quantity += quantity;
}
if (stockType == "Out")
{
prdctinfo.Quantity -= quantity;
}
}
catch (Exception ex)
{
if (ex is FormatException)
{
lblmsg.Text = "Character value are not allowed";
}
else
{
lblmsg.Text = ex.Message;
}
}
}
Put the breakpoint somewhere where it hits. Look at the call stack and step over to the point when you find why it is not going to the method you want to trigger.
Can't do much without more information.
Hope this helps
I saw few unwanted code's
1) please remove the ValidationGroup="vg1" in your all asp.net controls except button .
2) Don't use panel , some time the button click not working on using panel control, so please use table instead of panel .(or remove the asp:panel control )
3) and must check the button click event same as server side .
4) If you give me our server side code then i will response you !!
I have a calender selector that looks like
<asp:ImageButton ID="calStartImage" runat="server" ImageUrl="../images/SmallCalendar.gif"
AlternateText="Please select start date" />
<ajaxToolkit:CalendarExtender ID="calStartDate" runat="server" TargetControlID="txtStartDate"
Format="MM/dd/yyyy" PopupButtonID="calStartImage" />
And A search button that look like this
<asp:Button ID="btnSearch" runat="server" Text="Search" OnClick="btnSearch_Click"
CausesValidation="false" />
When I select a date from the calender and press Search..The first time btnSearch_Click doesnt fire..If I click Search again it works fine. So I have to click the Search button twice before the click event works. This only happens if I select a date from the calender control.
Here is the full control:
<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</ajaxToolkit:ToolkitScriptManager>
<table>
<tr>
<td class="SearchBox">
<table>
<tr>
<td colspan="2">
<b>Enter name to filter results</b>
<asp:TextBox ID="txtProjectName" runat="server"></asp:TextBox><br />
<br />
</td>
</tr>
<tr>
<td valign="middle">
<b>From:</b>
<asp:TextBox ID="txtStartDate" runat="server"></asp:TextBox>
<asp:ImageButton ID="calStartImage" runat="server" ImageUrl="../images/SmallCalendar.gif"
AlternateText="Please select start date" />
<ajaxToolkit:CalendarExtender ID="calStartDate" runat="server" TargetControlID="txtStartDate"
Format="MM/dd/yyyy" PopupButtonID="calStartImage" />
<b>Thru:</b>
<asp:TextBox ID="txtEndDate" runat="server"></asp:TextBox>
<asp:ImageButton runat="server" ID="calEndImage" ImageUrl="../images/SmallCalendar.gif"
AlternateText="Please select end date" />
<ajaxToolkit:CalendarExtender ID="calEndDate" runat="server" TargetControlID="txtEndDate"
Format="MM/dd/yyyy" PopupButtonID="calEndImage" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="From Date is Required"
ControlToValidate="txtStartDate" Display="Dynamic"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Thru Date is Required"
ControlToValidate="txtEndDate" Display="Dynamic"></asp:RequiredFieldValidator>
<asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="Invalid From Date"
ControlToValidate="txtStartDate" Display="Dynamic" MaximumValue="1/1/2099" MinimumValue="1/1/2006"
SetFocusOnError="True" Type="Date"></asp:RangeValidator>
<asp:RangeValidator ID="RangeValidator2" runat="server" ControlToValidate="txtEndDate"
ErrorMessage="Invalid Thru Date" SetFocusOnError="True" Type="Date" Display="Dynamic"
MaximumValue="1/1/2999" MinimumValue="1/1/2006"></asp:RangeValidator>
<br />
</td>
</tr>
<tr>
<td align="left">
<asp:Button ID="btnSearch" runat="server" Text="Search" OnClick="btnSearch_Click"
CausesValidation="false" />
</td>
</tr>
</table>
</td>
<td align="right" style="width:560px">
Guide
</td>
</tr>
</table>
Here is more from the page....
<ajaxToolkit:ModalPopupExtender ID="mdlPopupExtender" runat="server" TargetControlID="btnShowPopup"
PopupControlID="pnlProject" BackgroundCssClass="modalBackground" Drag="true"
DropShadow="true" CancelControlID="btnClose" PopupDragHandleControlID="TitleBar">
</ajaxToolkit:ModalPopupExtender>
<asp:Button ID="btnShowPopup" runat="server" Style="display: none" />
<asp:Panel ID="pnlProject" runat="server" BackColor="WhiteSmoke">
<asp:Panel ID="TitleBar" runat="server" CssClass="modalPopupTitleBar">
Add/Edit Project
</asp:Panel>
<asp:UpdatePanel ID="upPopList" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnAddNew" EventName="Click" />
</Triggers>
<ContentTemplate>
<table cellspacing="10">
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td>
<b>Project Name:</b>
</td>
<td>
<asp:TextBox ID="txtProject" runat="server" Width="200px"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqProject" runat="server" ErrorMessage="Required!"
Display="Dynamic" ControlToValidate="txtProject"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<b>Field Office:</b>
</td>
<td>
<asp:TextBox ID="txtFieldOffice" runat="server" Width="200px"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqFieldOffice" runat="server" ErrorMessage="Required!"
Display="Dynamic" ControlToValidate="txtFieldOffice"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<b>Created By:</b>
</td>
<td>
<asp:Label ID="lblCreatedBy" runat="server"></asp:Label>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
<table>
<tr>
<td>
<br />
<asp:Button ID="btnSubmit" runat="server" Text="Save" OnClick="btnSubmit_Click" />
<asp:Button ID="btnClose" runat="server" Text="Close" CausesValidation="false" />
<br />
</td>
</tr>
</table>
</asp:Panel>
Any Ideas?
You need to add ValidationGroup to your validation controls so that each validation group can perform validation independently from other validation group on a specific page. more you can read here Specifying Validation Groups
Here is your code with group validation. you can change it as your environment.
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<table>
<tr>
<td>
<table>
<tr>
<td colspan="2">
<b>Enter name to filter results</b>
<asp:TextBox ID="txtProjectName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td valign="middle">
<b>From:</b>
<asp:TextBox ID="txtStartDate" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="formDateRequiredValidator" ValidationGroup="Date"
runat="server" ErrorMessage="Enter From Date." ControlToValidate="txtStartDate"></asp:RequiredFieldValidator>
<asp:RangeValidator ID="RangeValidator1" runat="server" ValidationGroup="Date" ErrorMessage="Invalid From Date"
ControlToValidate="txtStartDate" Display="Dynamic" MaximumValue="1/1/2099" MinimumValue="1/1/2006"
SetFocusOnError="True" Type="Date"></asp:RangeValidator>
<asp:ImageButton ID="calStartImage" runat="server" AlternateText="Please select start date" />
<asp:CalendarExtender ID="calStartDate" runat="server" TargetControlID="txtStartDate"
Format="MM/dd/yyyy" PopupButtonID="calStartImage" />
<b>Thru:</b>
<asp:TextBox ID="txtEndDate" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="endDateRequiredValidator" ValidationGroup="Date"
runat="server" ErrorMessage="Enter Thru Date." ControlToValidate="txtEndDate"></asp:RequiredFieldValidator>
<asp:RangeValidator ID="RangeValidator2" ValidationGroup="Date" runat="server" ErrorMessage="Invalid From Date"
ControlToValidate="txtStartDate" Display="Dynamic" MaximumValue="1/1/2099" MinimumValue="1/1/2006"
SetFocusOnError="True" Type="Date"></asp:RangeValidator> 
<asp:ImageButton runat="server" ID="calEndImage" ImageUrl="../images/SmallCalendar.gif"
AlternateText="Please select end date" />
<asp:CalendarExtender ID="calEndDate" runat="server" TargetControlID="txtEndDate"
Format="MM/dd/yyyy" PopupButtonID="calEndImage" />
</td>
</tr>
<tr>
<td align="left">
<asp:Button ID="btnSearch" runat="server" Text="Search" ValidationGroup="Date" CausesValidation="false" />
</td>
</tr>
</table>
</td>
<td align="right">
Guide
</td>
</tr>
</table>
<asp:ModalPopupExtender ID="mdlPopupExtender" runat="server" TargetControlID="btnShowPopup"
PopupControlID="pnlProject" BackgroundCssClass="modalBackground" Drag="true"
DropShadow="true" CancelControlID="btnClose" PopupDragHandleControlID="TitleBar">
</asp:ModalPopupExtender>
<asp:Button ID="btnShowPopup" runat="server" Style="display: none" />
<asp:Panel ID="pnlProject" runat="server" BackColor="WhiteSmoke">
<asp:Panel ID="TitleBar" runat="server">
Add/Edit Project
<%-- I have added this Button you can replace with yours becaus specified in Triggers to run the code i need to add this(btnAddNew) Button--%>
<asp:Button ID="btnAddNew" runat="server" Text="AddNew" />
</asp:Panel>
<asp:UpdatePanel ID="upPopList" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnAddNew" />
</Triggers>
<ContentTemplate>
<table>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td>
<b>Project Name:</b>
</td>
<td>
<asp:TextBox ID="txtProject" runat="server" Width="200px"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqProject" ValidationGroup="ProjectInfo" runat="server"
ErrorMessage="Required!" Display="Dynamic" ControlToValidate="txtProject"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<b>Field Office:</b>
</td>
<td>
<asp:TextBox ID="txtFieldOffice" runat="server" Width="200px"></asp:TextBox>
<asp:RequiredFieldValidator ID="reqFieldOffice" ValidationGroup="ProjectInfo" runat="server"
ErrorMessage="Required!" Display="Dynamic" ControlToValidate="txtFieldOffice"></asp:RequiredFieldValidator>
</td>
</tr>
</td> </tr>
<tr>
<td>
<b>Created By:</b>
</td>
<td>
<asp:Label ID="lblCreatedBy" runat="server"></asp:Label>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
<table>
<tr>
<td>
<br />
<asp:Button ID="btnSubmit" runat="server" Text="Save" OnClick="btnSubmit_Click" />
<asp:Button ID="btnClose" runat="server" Text="Close" CausesValidation="false" ValidationGroup="ProjectInfo"
OnClick="btnClose_Click" />
<br />
</td>
</tr>
</table>
</asp:Panel>
Hope this helps.
I don't know why but your problem can be solved by setting the CausesValidation property of btnSearch to true
<asp:Button ID="btnSearch" runat="server" Text="Search" OnClick="btnSearch_Click"
CausesValidation="true" />
I am using a FormView control. The allows me to update records in the database. However, when a database field is null I can not update the field on the form. It works fine when the field is not a null value. I am not using any code behind (C#) to bind the data or manipulate the data.
I have read that when there is a null value in the database that there is no record in the "dataset". Can anyone show me how to bind a value in the form when there is a null value previously.
Thanks,
J
...
Total Records
<div style="width:1024px; text-align: justify; overflow:hidden; padding-top:0px">
<asp:GridView ID="DealershipGrid"
runat="server"
AllowPaging="True"
AllowSorting="True"
AutoGenerateColumns="False"
CellPadding="2"
DataKeyNames="Dealership_Id"
DataSourceID="DealershipsDS"
ForeColor="#333333"
GridLines="None"
Font-Names="Tahoma"
Font-Size="9pt"
Font-Bold="False"
Width="1024px" PageSize="10">
<PagerSettings Position="TopAndBottom" />
<FooterStyle BackColor="#8b1111" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#FFFFFF" ForeColor="#333333" Font-Names="Tahoma" Font-Size="8pt" />
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField
DataField="Dealership_Id"
HeaderText="ID"
InsertVisible="False"
ReadOnly="True"
SortExpression="Dealership_Id"
HeaderStyle-Width="3%"
ItemStyle-Width="3%"
FooterStyle-Width="3%" >
<FooterStyle Width="3%"></FooterStyle>
<HeaderStyle Width="3%" HorizontalAlign="Left"></HeaderStyle>
<ItemStyle Width="3%"></ItemStyle>
</asp:BoundField>
<asp:BoundField
DataField="Dealership_Name"
HeaderText="Dealership"
SortExpression="Dealership_Name"
HeaderStyle-Width="18%"
ItemStyle-Width="18%"
FooterStyle-Width="18%">
<FooterStyle Width="18%"></FooterStyle>
<HeaderStyle Width="18%" HorizontalAlign="Left"></HeaderStyle>
<ItemStyle Width="18%"></ItemStyle>
</asp:BoundField>
<asp:BoundField
DataField="Dealership_BranchName"
HeaderText="Branch"
SortExpression="Dealership_BranchName"
HeaderStyle-Width="18%"
ItemStyle-Width="18%"
FooterStyle-Width="18%">
<FooterStyle Width="18%"></FooterStyle>
<HeaderStyle Width="18%" HorizontalAlign="Left"></HeaderStyle>
<ItemStyle Width="18%"></ItemStyle>
</asp:BoundField>
<asp:BoundField
DataField="Dealership_Phone1"
HeaderText="Phone"
SortExpression="Dealership_Phone1"
HeaderStyle-Width="9%"
ItemStyle-Width="9%"
FooterStyle-Width="9%" >
<FooterStyle Width="9%"></FooterStyle>
<HeaderStyle Width="9%" HorizontalAlign="Left"></HeaderStyle>
<ItemStyle Width="9%"></ItemStyle>
</asp:BoundField>
<asp:BoundField
DataField="Dealership_Email1"
HeaderText="Email"
SortExpression="Dealership_Email1"
HeaderStyle-Width="37%"
ItemStyle-Width="37%"
FooterStyle-Width="37%">
<FooterStyle Width="37%"></FooterStyle>
<HeaderStyle Width="37%" HorizontalAlign="Left"></HeaderStyle>
<ItemStyle Width="37%"></ItemStyle>
</asp:BoundField>
<asp:BoundField
DataField="Dealership_State"
HeaderText="State"
SortExpression="Dealership_State"
HeaderStyle-Width="5%"
ItemStyle-Width="5%"
FooterStyle-Width="5%" >
<FooterStyle Width="5%"></FooterStyle>
<HeaderStyle Width="5%" HorizontalAlign="Left"></HeaderStyle>
<ItemStyle Width="5%"></ItemStyle>
</asp:BoundField>
<asp:BoundField
DataField="Dealership_ZipCode"
HeaderText="Zip Code"
SortExpression="Dealership_ZipCode"
HeaderStyle-Width="6%"
ItemStyle-Width="6%"
FooterStyle-Width="6%" >
<FooterStyle Width="6%"></FooterStyle>
<HeaderStyle Width="6%" HorizontalAlign="Left"></HeaderStyle>
<ItemStyle Width="6%"></ItemStyle>
</asp:BoundField>
</Columns>
<PagerStyle BackColor="White" ForeColor="Maroon" HorizontalAlign="Right" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="False" ForeColor="#333333" />
<HeaderStyle BackColor="#AB1414" Font-Bold="True" ForeColor="White" Font-Names="Tahoma" Font-Size="9pt" HorizontalAlign="Left" />
<EditRowStyle BackColor="#999999" ForeColor="Black" />
<AlternatingRowStyle BackColor="Silver" ForeColor="Black" />
</asp:GridView>
ConnectionString="<%$ ConnectionStrings:driveaway2day2 %>"
SelectCommand="SELECT [Dealership_Id], [Dealership_Name], [Dealership_BranchName], [Dealership_Phone1], [Dealership_Email1], [Dealership_State], [Dealership_ZipCode] FROM [CAR_Dealership] ORDER BY [Dealership_Name]" EnableViewState="False" OnSelected="DealershipsDS_Selected" >
</asp:SqlDataSource>
Dealership Details
Dealership ID
<%# Eval("Dealership_Id")%>
Email 1
<%# Eval("Dealership_Email1")%>
Dealership
<%# Eval("Dealership_Name")%>
Email 2
<%# Eval("Dealership_Email2")%>
Branch Name
<%# Eval("Dealership_BranchName")%>
Email 3
<%# Eval("Dealership_Email3")%>
Phone 1
<%# Eval("Dealership_Phone1")%>
Address
<%# Eval("Dealership_Address")%>
Phone 2
<%# Eval("Dealership_Phone2")%>
City
<%# Eval("Dealership_City")%>
Phone 3
<%# Eval("Dealership_Phone3")%>
State
<%# Eval("Dealership_State")%>
Fax
<%# Eval("Dealership_Fax")%>
Zip Code
<%# Eval("Dealership_ZipCode")%>
<tr>
<td colspan="4" style="padding-top:5px;height:15px; background-color:#E2DED6;"> </td>
</tr>
<tr>
<td colspan="4" style="padding-top:5px;height:15px;"> </td>
</tr>
<tr>
<td colspan="2" style="padding-top:5px;">
<asp:Button ID="btnEdit" runat="Server" CommandName="Edit" Text="Edit" Font-Names="Tahoma" Font-Size="10px" />
<asp:Button ID="btnInsert" runat="Server" CommandName="New" Text="New" Font-Names="tahoma" Font-Size="10px" />
<asp:Button ID="btnDelete" runat="Server" CommandName="Delete" Text="Delete" OnClientClick="return confirm('Are you sure to Delete?');" Font-Size="10px" Font-Names="tahoma" />
</td>
</tr>
</table>
</ItemTemplate>
<EditItemTemplate>
<table border="0" width="1024px" style="padding-top:0px;">
<tr>
<td height="20px" colspan="4" style="padding-top:0px;"> </td>
</tr>
<tr>
<td colspan="4" style="padding-left:3px;height:20px; background-color:#E2DED6; font-family: Tahoma; font-size:12px; color:#000000; font-weight:bold; width:1024px;">Dealership Details</td>
</tr>
<tr>
<td>
<table width="800px">
<tr>
<td colspan="4" style="padding-top:5px;height:5px;"> </td>
</tr>
<tr>
<td style="padding-top:5px;" width="100px">Dealership ID</td>
<td style="padding-top:5px;" width="300px"><%# Eval("Dealership_Id")%></td>
<td style="padding-top:5px;" width="100px">Email 1</td>
<td style="padding-top:5px;" width="300px">
<asp:TextBox class="aclDetTxt" ID="TextBox1" runat="Server" Text='<%# Bind("Dealership_Email1")%>'>
</asp:TextBox>
</td>
</tr>
<tr>
<td style="padding-top:5px;" width="100px">Dealership</td>
<td style="padding-top:5px;" width="300px">
<asp:TextBox class="aclDetTxt" ID="TextBox2" runat="Server" Text='<%# Bind("Dealership_Name")%>'>
</asp:TextBox></td>
<td style="padding-top:5px;" width="100px">Email 2</td>
<td style="padding-top:5px;" width="300px">
<asp:TextBox class="aclDetTxt" ID="TextBox3" runat="Server" Text='<%# Bind("Dealership_Email2")%>'>
</asp:TextBox>
</td>
</tr>
<tr>
<td style="padding-top:5px;" width="100px">Branch Name</td>
<td style="padding-top:5px;" width="300px">
<asp:TextBox class="aclDetTxt" ID="TextBox4" runat="Server" Text='<%# Bind("Dealership_BranchName")%>'>
</asp:TextBox>
</td>
<td style="padding-top:5px;" width="100px">Email 3</td>
<td style="padding-top:5px;" width="300px">
<asp:TextBox class="aclDetTxt" ID="TextBox5" runat="Server" Text='<%# Bind("Dealership_Email3")%>'>
</asp:TextBox>
</td>
</tr>
<tr>
<td style="padding-top:5px;" width="100px">Phone 1</td>
<td style="padding-top:5px;" width="300px">
<asp:TextBox class="aclDetTxt" ID="TextBox6" runat="Server" Text='<%# Bind("Dealership_Phone1")%>'>
</asp:TextBox>
</td>
<td style="padding-top:5px;" width="100px">Address</td>
<td style="padding-top:5px;" width="300px">
<asp:TextBox class="aclDetTxt" ID="TextBox7" runat="Server" Text='<%# Bind("Dealership_Address")%>'>
</asp:TextBox>
</td>
</tr>
<tr>
<td style="padding-top:5px;" width="100px">Phone 2</td>
<td style="padding-top:5px;" width="300px">
<asp:TextBox class="aclDetTxt" ID="TextBox8" runat="Server" Text='<%# Bind("Dealership_Phone2")%>'>
</asp:TextBox>
</td>
<td style="padding-top:5px;" width="100px">City</td>
<td style="padding-top:5px;" width="300px">
<asp:TextBox class="aclDetTxt" ID="TextBox9" runat="Server" Text='<%# Bind("Dealership_City")%>'>
</asp:TextBox>
</td>
</tr>
<tr>
<td style="padding-top:5px;" width="100px">Phone 3</td>
<td style="padding-top:5px;" width="300px">
<asp:TextBox class="aclDetTxt" ID="TextBox10" runat="Server" Text='<%# Bind("Dealership_Phone3")%>'>
</asp:TextBox>
</td>
<td style="padding-top:5px;" width="100px">State</td>
<td style="padding-top:5px;" width="300px">
<asp:DropDownList class="aclDetDD" ID="myDropDownList" runat="server"
AppendDataBoundItems="True"
DataSourceID="StatesDS"
DataValueField="Dealership_State"
DataTextField="name"
SelectedValue='<%#Bind("Dealership_State") %>'>
<asp:ListItem Value="">Select a State...
</asp:ListItem>
</asp:DropDownList>
<asp:XmlDataSource ID="StatesDS" runat="server" DataFile="~/Ddl/States.xml">
</asp:XmlDataSource>
</td>
</tr>
<tr>
<td style="padding-top:5px;" width="100px">Fax</td>
<td style="padding-top:5px;" width="300px">
<asp:TextBox class="aclDetTxt" ID="TextBox12" runat="Server" Text='<%# Bind("Dealership_Fax")%>'>
</asp:TextBox>
</td>
<td style="padding-top:5px;" width="100px">Zip Code</td>
<td style="padding-top:5px;" width="300px">
<asp:TextBox class="aclDetTxt" ID="TextBox13" runat="Server" Text='<%# Bind("Dealership_ZipCode")%>'>
</asp:TextBox>
</td>
</tr>
<tr>
<td colspan="4" style="padding-top:5px;height:5px;"> </td>
</tr>
</tr>
</table>
</td>
<tr>
<td colspan="4" style="padding-top:5px;height:15px; background-color:#E2DED6;"> </td>
</tr>
<tr>
<td colspan="4" style="padding-top:5px;height:15px;"> </td>
</tr>
<asp:RequiredFieldValidator ID="req1" runat="Server" ControlToValidate="TextBox1" ErrorMessage="Email 1 is Required" Text="Enter Correct Information.">
</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="Server" ControlToValidate="TextBox2" ErrorMessage="Dealership is Required" Text="Enter Correct Information.">
</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="Server" ControlToValidate="TextBox6" ErrorMessage="Phone 1 is Required" Text="Enter Correct Information.">
</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="Server" ControlToValidate="TextBox7" ErrorMessage="Address is Required" Text="Enter Correct Information.">
</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="Server" ControlToValidate="TextBox9" ErrorMessage="City is Required" Text="Enter Correct Information.">
</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="Server" ControlToValidate="TextBox13" ErrorMessage="Zip Code is Required" Text="Enter Correct Information.">
</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="Server" ControlToValidate="TextBox4" ErrorMessage="Branch/Location is Required" Text="Enter Correct Information.">
</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="Server" ControlToValidate="myDropDownList" ErrorMessage="State is Required" Text="Enter Correct Information.">
</asp:RequiredFieldValidator>
<tr>
<td colspan="2" style="padding-top:5px;">
<asp:Button ID="btnUpdate" runat="Server" CommandName="Update" Text="Update" Font-Names="tahoma" Font-Size="10px" />
<asp:Button ID="Button1" runat="Server" CommandName="Cancel" Text="Cancel" CausesValidation="False" Font-Names="tahoma" Font-Size="10px" />
</td>
</tr>
<asp:ValidationSummary ID="ValidationSummary" runat="Server" ShowMessageBox="true" />
</table>
</EditItemTemplate>
Dealership Details
Dealership ID
<%# Eval("Dealership_Id")%>
Email 1
'>
Dealership
'>
Email 2
'>
Branch Name
'>
Email 3
'>
Phone 1
'>
Address
'>
Phone 2
'>
City
'>
Phone 3
'>
State
You might have to set null fields to default values in your dataset.