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 !!
Related
I have an aspx page containing a grid-view. During a post-back of the grid, the data bound to the grid-view are lost. What could be the reason?
I have attached code below which the user input data on controls disappears when the image button is clicked.
aspx page:
<telerik:RadGrid ID="GridOfficeInfo" runat="server" AllowMultiRowSelection="false" OnItemCommand="GridOfficeInfo_ItemCommand" BorderWidth="0" AutoGenerateColumns="false" Width="100%" Visible="true" >
<MasterTableView>
<Columns>
<telerik:GridTemplateColumn>
<HeaderStyle BorderWidth="0" HorizontalAlign="Center" CssClass="OfficeInfoHeader" />
<ItemStyle BorderWidth="0" HorizontalAlign="Center" CssClass="OfficeRow" />
<HeaderTemplate>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left">
<asp:Label runat="server" ID="Label1" Text="Office Info" CssClass="Label">
</asp:Label>
</td>
<%-- <td align="right">
<asp:LinkButton ID="lnkOfficeInfo" runat="server" Font-Underline="true" Text="Click here for map" OnClick="lnkOfficeInfo_Click" CssClass="Label">
</asp:LinkButton>
</td>
--%>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table id="TableOfficeinfo" border="0" width="100%" runat="server">
<col style="width:16%;" />
<col style="width:18%;" />
<col style="width:15%;" />
<col style="width:18%;" />
<col style="width:15%;" />
<col style="width:18%;" />
<tr>
<td align="left" colspan="2" style="border-width:0;">
<asp:Label ID="LblOffice" Text="Primary Practice Location" runat="server" CssClass="LabelItalics">
</asp:Label>
</td>
<td align="left" style="border-width:0;">
<asp:Label ID="LblBillAdd" Text="Billing Address" runat="server" CssClass="Label">
</asp:Label>
</td>
<td align="left" style="border-width:0;">
<asp:CheckBox runat="server" ID="ChkBillAdd" Checked="false" CssClass="ProviderCb" AutoPostBack="true" OnCheckedChanged="ChkBillAdd_CheckedChanged" />
</td>
<td align="right" colspan="2" style="border-width:0;">
<asp:LinkButton ID="lnkOfficeMap" runat="server" Font-Underline="true" Text="Click here for map" OnClick="lnkOfficeInfo_Click" CssClass="Label">
</asp:LinkButton>
</td>
</tr>
<tr>
<td align="left" style="border-width:0;">
<asp:Label ID="LblStreet" Text="Street Address" runat="server" CssClass="Label">
</asp:Label>
</td>
<td align="left" style="border-width:0;">
<asp:TextBox runat="server" ID="TxtStreet" Text='<%#Eval("StreetAddress")%>' Enabled="false" CssClass="ProviderTextbox">
</asp:TextBox>
</td>
<td align="left" style="border-width:0;">
<asp:Label ID="LblSuite" Text="Suite" runat="server" CssClass="Label">
</asp:Label>
</td>
<td align="left" style="border-width:0;">
<asp:TextBox runat="server" ID="TxtSuite" Text='<%#Eval("Suite")%>' Enabled="false" CssClass="ProviderTextbox">
</asp:TextBox>
</td>
<td align="left" style="border-width:0;">
<asp:Label runat="server" ID="LblCity" Text="City" CssClass="Label">
</asp:Label>
</td>
<td align="left" style="border-width:0;">
<asp:TextBox runat="server" ID="TxtCity" Text='<%#Eval("City")%>' Enabled="false" CssClass="ProviderTextbox">
</asp:TextBox>
</td>
</tr>
<tr>
<td align="left" style="border-width:0;">
<asp:Label ID="LblState" Text="State" runat="server" CssClass="Label">
</asp:Label>
</td>
<td align="left" style="border-width:0;">
<asp:TextBox runat="server" ID="TxtState" Text='<%#Eval("State")%>' Enabled="false" CssClass="ProviderTextbox">
</asp:TextBox>
<telerik:RadComboBox runat="server" ID="cbOfficeInfo" CssClass="ProviderCombo" Visible="false" EnableTextSelection="true" SortCaseSensitive="false" Height="100">
<Items>
<telerik:RadComboBoxItem runat="server" Text="Choose State" />
<telerik:RadComboBoxItem runat="server" Text="AL" />
<telerik:RadComboBoxItem runat="server" Text="AK" />
<telerik:RadComboBoxItem runat="server" Text="AZ" />
<telerik:RadComboBoxItem runat="server" Text="AR" />
<telerik:RadComboBoxItem runat="server" Text="CA" />
<telerik:RadComboBoxItem runat="server" Text="CO" />
<telerik:RadComboBoxItem runat="server" Text="CT" />
<telerik:RadComboBoxItem runat="server" Text="DE" />
<telerik:RadComboBoxItem runat="server" Text="DC" />
<telerik:RadComboBoxItem runat="server" Text="FL" />
<telerik:RadComboBoxItem runat="server" Text="GA" />
<telerik:RadComboBoxItem runat="server" Text="HI" />
<telerik:RadComboBoxItem runat="server" Text="ID" />
<telerik:RadComboBoxItem runat="server" Text="IL" />
<telerik:RadComboBoxItem runat="server" Text="IN" />
<telerik:RadComboBoxItem runat="server" Text="IA" />
<telerik:RadComboBoxItem runat="server" Text="KS" />
<telerik:RadComboBoxItem runat="server" Text="KY" />
<telerik:RadComboBoxItem runat="server" Text="LA" />
<telerik:RadComboBoxItem runat="server" Text="ME" />
<telerik:RadComboBoxItem runat="server" Text="MD" />
<telerik:RadComboBoxItem runat="server" Text="MA" />
<telerik:RadComboBoxItem runat="server" Text="MI" />
<telerik:RadComboBoxItem runat="server" Text="MN" />
<telerik:RadComboBoxItem runat="server" Text="MS" />
<telerik:RadComboBoxItem runat="server" Text="MO" />
<telerik:RadComboBoxItem runat="server" Text="MT" />
<telerik:RadComboBoxItem runat="server" Text="NE" />
<telerik:RadComboBoxItem runat="server" Text="NV" />
<telerik:RadComboBoxItem runat="server" Text="NH" />
<telerik:RadComboBoxItem runat="server" Text="NJ" />
<telerik:RadComboBoxItem runat="server" Text="NM" />
<telerik:RadComboBoxItem runat="server" Text="NY" />
<telerik:RadComboBoxItem runat="server" Text="NC" />
<telerik:RadComboBoxItem runat="server" Text="ND" />
<telerik:RadComboBoxItem runat="server" Text="OH" />
<telerik:RadComboBoxItem runat="server" Text="OK" />
<telerik:RadComboBoxItem runat="server" Text="OR" />
<telerik:RadComboBoxItem runat="server" Text="PA" />
<telerik:RadComboBoxItem runat="server" Text="RI" />
<telerik:RadComboBoxItem runat="server" Text="SC" />
<telerik:RadComboBoxItem runat="server" Text="SD" />
<telerik:RadComboBoxItem runat="server" Text="TN" />
<telerik:RadComboBoxItem runat="server" Text="TX" />
<telerik:RadComboBoxItem runat="server" Text="UT" />
<telerik:RadComboBoxItem runat="server" Text="VT" />
<telerik:RadComboBoxItem runat="server" Text="VA" />
<telerik:RadComboBoxItem runat="server" Text="WA" />
<telerik:RadComboBoxItem runat="server" Text="WV" />
<telerik:RadComboBoxItem runat="server" Text="WI" />
<telerik:RadComboBoxItem runat="server" Text="WY" />
</Items>
</telerik:RadComboBox>
</td>
<td align="left" style="border-width:0;">
<asp:Label ID="LblZip" Text="Zip" runat="server" CssClass="Label">
</asp:Label>
</td>
<td align="left" style="border-width:0;">
<asp:TextBox runat="server" ID="TxtZip" Text='<%#Eval("Zip")%>' Enabled="false" CssClass="ProviderTextbox">
</asp:TextBox>
</td>
<td align="left" style="border-width:0;">
<asp:Label runat="server" ID="LblContact" Text="Office Contact" CssClass="Label">
</asp:Label>
</td>
<td align="left" style="border-width:0;">
<asp:TextBox runat="server" ID="TxtContact" Text='<%#Eval("OfficeContact")%>' Enabled="true" CssClass="ProviderTextbox">
</asp:TextBox>
</td>
</tr>
<tr>
<td align="left" style="border-width:0;">
<asp:Label ID="LblEMRUsed" Text="EMR Used" runat="server" CssClass="Label">
</asp:Label>
</td>
<td align="left" style="border-width:0;">
<telerik:RadComboBox runat="server" ID="CbEMRUsed" EnableTextSelection="true" CssClass="ProviderCombo" AutoPostBack="true" OnSelectedIndexChanged="CbEMRUsed_SelectedIndexChanged">
<Items>
<telerik:RadComboBoxItem runat="server" Text="Yes" />
<telerik:RadComboBoxItem runat="server" Text="No" />
</Items>
</telerik:RadComboBox>
</td>
<td align="left" style="border-width:0;">
<asp:Label ID="LblEMRName" Text="EMR Name" runat="server" CssClass="Label">
</asp:Label>
</td>
<td align="left" style="border-width:0;">
<telerik:RadComboBox runat="server" ID="CbEMRName" EnableTextSelection="true" CssClass="ProviderCombo" Height="200">
<Items>
<telerik:RadComboBoxItem runat="server" Text="Select" Selected="true" />
</Items>
</telerik:RadComboBox>
</td>
<td align="left" style="border-width:0;">
<asp:Label runat="server" ID="LblUse" Text="Meaningful Use" CssClass="Label">
</asp:Label>
</td>
<td align="left" style="border-width:0;">
<asp:CheckBox runat="server" ID="MeaningUse" Checked="false" CssClass="ProviderCb" AutoPostBack="true" OnCheckedChanged="MeaningUse_CheckedChanged"/>
</td>
</tr>
<tr>
<td align="left" style="border-width:0;">
<asp:Label ID="LblOffTel1" Text="Office Tel # 1" runat="server" CssClass="Label">
</asp:Label>
</td>
<td align="left" style="border-width:0;">
<telerik:RadMaskedTextBox ID="TxtOffTel1" runat="server" Enabled="false" Mask="(###) ###-####" Width="88.5%" Text='<%#Eval("OfficeTel_1")%>' DisabledStyle-BackColor="#E5E5E5">
</telerik:RadMaskedTextBox>
<%--<asp:TextBox runat="server" ID="TxtOffTel1" Text='<%#Eval("OfficeTel_1")%>' Enabled="false" CssClass="ProviderTextbox">
</asp:TextBox>--%>
</td>
<td align="left" style="border-width:0;">
<asp:Label ID="LblOffTel2" Text="Office Tel # 2" runat="server" CssClass="Label">
</asp:Label>
</td>
<td align="left" style="border-width:0;">
<telerik:RadMaskedTextBox ID="TxtOffTel2" runat="server" Enabled="false" Mask="(###) ###-####" Width="88.5%" Text='<%#Eval("OfficeTel_2")%>' DisabledStyle-BackColor="#E5E5E5">
</telerik:RadMaskedTextBox>
<%--<asp:TextBox runat="server" ID="TxtOffTel2" Text='<%#Eval("OfficeTel_2")%>' Enabled="false" CssClass="ProviderTextbox">
</asp:TextBox>--%>
</td>
<td align="left" style="border-width:0;">
<asp:Label runat="server" ID="LblOffFax" Text="Office Fax" CssClass="Label">
</asp:Label>
</td>
<td align="left" style="border-width:0;">
<telerik:RadMaskedTextBox ID="TxtOffFax" runat="server" Enabled="false" Mask="(###) ###-####" Width="88.5%" Text='<%#Eval("OfficeFax")%>' DisabledStyle-BackColor="#E5E5E5">
</telerik:RadMaskedTextBox>
<%--<asp:TextBox runat="server" ID="TxtOffFax" Text='<%#Eval("OfficeFax")%>' Enabled="false" CssClass="ProviderTextbox">
</asp:TextBox>--%>
</td>
</tr>
<tr>
<td align="left" style="border-width:0;">
<asp:Label ID="LblIDTCount" Text="IDT Assigned Count" runat="server" CssClass="Label">
</asp:Label>
</td>
<td align="left" style="border-width:0;">
<asp:TextBox runat="server" ID="TxtIDTCount" Text='<%#Eval("IDTAssignedCount")%>' Enabled="false" CssClass="ProviderTextbox">
</asp:TextBox>
</td>
<td align="left" style="border-width:0;">
<asp:Label ID="LblLastDate" Text="Last Visit Date" runat="server" CssClass="Label">
</asp:Label>
</td>
<td align="left" style="border-width:0;">
<telerik:RadDatePicker runat="server" ID="DpLastDate" CssClass="ProviderDtpicker">
<DateInput DateFormat="MM/dd/yyyy">
</DateInput>
</telerik:RadDatePicker>
</td>
<td align="left" style="border-width:0;">
<asp:Label runat="server" ID="LblWaitTime" Text="Avg. Wait Time" CssClass="Label">
</asp:Label>
</td>
<td align="left" style="border-width:0;">
<asp:TextBox runat="server" ID="TxtWaitTime" Text='<%#Eval("AvgWaitTime")%>' Enabled="false" CssClass="ProviderTextbox">
</asp:TextBox>
</td>
</tr>
<tr id="trAddOffice" runat="server">
<td align="left" colspan="6" style="border-width:0;">
<asp:ImageButton ID="AddOfficeRow" runat="server" UseSubmitBehavior="false" ImageUrl="~/Images/AddDiag1.png" OnClick="AddOfficeRow_Click" />
</td>
</tr>
</table>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
<ClientSettings >
</ClientSettings>
</telerik:RadGrid>
aspx.cs page
protected void AddOfficeRow_Click(object sender, ImageClickEventArgs e)
{
//int Rno = GridOfficeInfo.Items.Count + 1;
int Rno = GridOfficeInfo.Items.Count + 1;
PopulateGridOfficeInfo(Rno);
}
public void PopulateGridOfficeInfo(int RowNo)
{
//bool[] bBillingAddress = new bool[RowNo - 1];
//bool[] bMeaningfulUse = new bool[RowNo - 1];
string strCbEMRUsed = string.Empty;
string strCbEMRName = string.Empty;
string strcbOfficeInfo = string.Empty;
DataTable dt = new DataTable();
dt.Columns.Add("StreetAddress");//Text='<%#Eval("StreetAddress")%>'
dt.Columns.Add("Suite");//
dt.Columns.Add("City");//
dt.Columns.Add("State");//
dt.Columns.Add("Zip");//
dt.Columns.Add("OfficeContact");//
dt.Columns.Add("OfficeTel_1");//
dt.Columns.Add("OfficeTel_2");//
dt.Columns.Add("OfficeFax");//
dt.Columns.Add("IDTAssignedCount");//
//dt.Columns.Add("LastDate", typeof(DateTime?));
dt.Columns.Add("AvgWaitTime");//
for (int i = 0; i < RowNo; i++)
{
//string lnkOfficeMap = string.Empty;
string StreetAddress = string.Empty;
string Suite = string.Empty;
string City = string.Empty;
string State = string.Empty;
string Zip = string.Empty;
string OfficeContact = string.Empty;
string OfficeTel_1 = string.Empty;
string OfficeTel_2 = string.Empty;
string OfficeFax = string.Empty;
string IDTAssignedCount = string.Empty;
string AvgWaitTime = string.Empty;
if (i < RowNo - RowNo)
{
//bBillingAddress[i] = ((CheckBox)GridOfficeInfo.Items[i].FindControl("ChkBillAdd")).Checked;
//lnkOfficeMap = ((LinkButton)GridOfficeInfo.Items[i].FindControl("Click here for map")).Text;
StreetAddress = ((TextBox)GridOfficeInfo.Items[i].FindControl("TxtStreet")).Text;
Suite = ((TextBox)GridOfficeInfo.Items[i].FindControl("TxtSuite")).Text;
City = ((TextBox)GridOfficeInfo.Items[i].FindControl("TxtCity")).Text;
State = ((TextBox)GridOfficeInfo.Items[i].FindControl("TxtState")).Text;
Zip = ((TextBox)GridOfficeInfo.Items[i].FindControl("TxtZip")).Text;
OfficeContact = ((TextBox)GridOfficeInfo.Items[i].FindControl("TxtContact")).Text;
//bMeaningfulUse[i] = ((CheckBox)GridOfficeInfo.Items[i].FindControl("MeaningUse")).Checked;
OfficeTel_1 = ((RadMaskedTextBox)GridOfficeInfo.Items[i].FindControl("TxtOffTel1")).Text;
//OfficeTel_1 = ((TextBox)GridOfficeInfo.Items[i].FindControl("TxtOffTel1")).Text;
OfficeTel_2 = ((RadMaskedTextBox)GridOfficeInfo.Items[i].FindControl("TxtOffTel2")).Text;
//OfficeTel_2 = ((TextBox)GridOfficeInfo.Items[i].FindControl("TxtOffTel2")).Text;
OfficeFax = ((RadMaskedTextBox)GridOfficeInfo.Items[i].FindControl("TxtOffFax")).Text;
//OfficeFax = ((TextBox)GridOfficeInfo.Items[i].FindControl("TxtOffFax")).Text;
IDTAssignedCount = ((TextBox)GridOfficeInfo.Items[i].FindControl("TxtIDTCount")).Text;
AvgWaitTime = ((TextBox)GridOfficeInfo.Items[i].FindControl("TxtWaitTime")).Text;
}
dt.Rows.Add(StreetAddress, Suite, City, State, Zip, OfficeContact, OfficeTel_1, OfficeTel_2, OfficeFax, IDTAssignedCount, AvgWaitTime);
}
GridOfficeInfo.DataSource = dt;
GridOfficeInfo.DataBind();
}
Use the NeedDataSource event to provide a datasource. My best guess is that it no longer has a datasource after a postback: https://demos.telerik.com/aspnet-ajax/grid/examples/data-binding/simple-vs-advanced/defaultcs.aspx. You will see how often you need to provide datasource when you do it manually.
Similar problems can arise if you disable viewstate too.
Here I had given "Showfooter"=true property but still it's not displaying
But while debug value(sumofamount) is assign to label.text
My GridView Code:
<asp:GridView ID="gvGrossDetails" runat="server" AllowPaging="true" AutoGenerateColumns="false"
CellPadding="0" CellSpacing="1" CssClass="grid_bg" GridLines="None" DataKeyNames="Code"
OnRowEditing="gvPayeeGross_RowEditing" OnRowDeleting="gvGrossDetails_RowDeleting"
OnRowUpdating="gvGrossDetails_RowUpdating" OnRowCancelingEdit="gvGrossDetails_RowCancelingEdit"
PagerStyle-Width="0px" PageSize="10" ShowFooter="true" Width="112%" Style="margin-top: 0px">
<PagerStyle CssClass="hide" />
<SelectedRowStyle CssClass="tble_hdr_not_sltd" />
<HeaderStyle CssClass="tble_hdr_not_sltd" />
<EmptyDataRowStyle CssClass="row_odd" HorizontalAlign="Center" />
<FooterStyle CssClass="hide" />
<RowStyle CssClass="row_even" />
<EmptyDataTemplate>
<table class="confirmation" cellpadding="0" cellspacing="0">
<tr>
<td>
<asp:Label Text="Records not found" ID="lblEmpty" runat="server"></asp:Label>
</td>
</tr>
</table>
</EmptyDataTemplate>
<AlternatingRowStyle CssClass="row_odd" />
<Columns>
<asp:TemplateField Visible="false">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblPayeeID1" runat="server" Text='<%#Bind("Code") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="0%" />
<HeaderStyle />
</asp:TemplateField>
<asp:TemplateField Visible="false">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblPayeeCode" runat="server" Text='<%#Bind("Code") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="0%" />
<HeaderStyle />
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="20%" HeaderStyle-HorizontalAlign="Left">
<HeaderTemplate>
Account head
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblGrossType" runat="server" Text='<%# Bind("Accounthead") %>' Wrap="true"></asp:Label>
</ItemTemplate>
<ItemStyle CssClass="item_Style1" />
<EditItemTemplate>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="middle" width="50%">
<asp:Label ID="txtGrossType" runat="server" Text='<%# Bind("Accounthead")%>'
CssClass="black_normal" Width="110px"></asp:Label>
</td>
</tr>
</table>
</EditItemTemplate>
<ItemStyle Width="20%" />
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="13%" HeaderStyle-HorizontalAlign="Left">
<HeaderTemplate>
Payee Amount
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblPresentedAmount" runat="server" Text=' <%# Eval("PayeeAmount")%>' Wrap="true"></asp:Label>
</ItemTemplate>
<ItemStyle CssClass="item_Style1" />
<EditItemTemplate>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="middle">
<asp:Label ID="txtPresentedAmount" runat="server" Text='<%# Bind("PayeeAmount")%>'
CssClass="black_normal" onblur="requiredCheck(this);" MaxLength="5" Width="110px"></asp:Label>
</td>
</tr>
</table>
</EditItemTemplate>
<FooterTemplate>
<asp:Label Text=Text='<%# GetTotalSalary() %>' ID="lbltotal" runat="server"></asp:Label>
</FooterTemplate>
<ItemStyle Width="13%" />
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="13%" HeaderStyle-HorizontalAlign="Left">
<HeaderTemplate>
Approved Amount
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblApproveAmount" runat="server" Text='<%# Eval("ApprovedAmount")%>'
Wrap="true"></asp:Label>
</ItemTemplate>
<ItemStyle CssClass="item_Style1" />
<EditItemTemplate>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="middle">
<asp:TextBox ID="txtApproveAmount" runat="server" Text='<%# Bind("ApprovedAmount")%>'
CssClass="black_normal" onblur="requiredCheck(this);" MaxLength="5" Width="110px"></asp:TextBox>
<ajaxToolkit:FilteredTextBoxExtender ID="fltrApprove" runat="server" FilterType="Custom"
FilterMode="InvalidChars" InvalidChars="'abcdefghijklmnopqrstuvwxyz#!#$%^&*%<> ,"
TargetControlID="txtApproveAmount">
</ajaxToolkit:FilteredTextBoxExtender>
</td>
</tr>
</table>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="approrve" runat="server"></asp:TextBox>
</FooterTemplate>
<ItemStyle Width="13%" />
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="6%">
<HeaderTemplate>
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="cursor: pointer;
cursor: hand;">
<tr>
<td align="right" style="display: none" valign="middle">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" width="70%">
<a>Delete</a>
</td>
<td style="width: 6px">
</td>
</tr>
</table>
</td>
<td align="right" valign="middle">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" width="70%">
<a>Delete</a>
</td>
<td style="width: 6px">
</td>
</tr>
</table>
</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table cellpadding="0" cellspacing="0" border="0" style="padding-left: 3px">
<tr>
<td align="right" height="19px" valign="middle">
<asp:Button ID="btnSEdit" CssClass="btnEdit" runat="server" CommandName="Edit" UseSubmitBehavior="false"
CausesValidation="false" />
</td>
<td align="right" height="19px" valign="middle">
<asp:Button ID="btnSDelete" CssClass="btnDelete" runat="server" CommandName="delete"
UseSubmitBehavior="false" CausesValidation="false" />
</td>
</tr>
</table>
</ItemTemplate>
<EditItemTemplate>
<table cellpadding="0" cellspacing="0">
<tr>
<td align="right" valign="middle" nowrap>
<asp:Button ID="btnSUpdate" CssClass="btnUpdate" runat="server" CommandName="Update"
UseSubmitBehavior="false" ValidationGroup="GSave" CausesValidation="false" />
<asp:Button ID="btnSCancel" CssClass="btnCancel" runat="server" CommandName="Cancel"
UseSubmitBehavior="false" CausesValidation="false" />
</td>
</tr>
</table>
</EditItemTemplate>
<ItemStyle Width="6%" />
</asp:TemplateField>
</Columns>
</asp:GridView>
sumof total
if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Separator)
{
total += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "GrossAmount"));
}
if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Separator)
{
total += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "ApprovedAmount"));
}
if (e.Row.RowType == DataControlRowType.Footer)
{
Label lblamount = (Label)e.Row.FindControl("lblgrossamount");
lblamount.Text = total.ToString();
}
Here i had given "Showfooter"=true property but still it's not displaying
But while debug value(sumofamount) is assign to label.text
this line apply css for the gridview infooter:
<FooterStyle CssClass="hide" />
i think that this can hide the footr of gridview pls check this css...
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
I have table containing gridview inside an update panel "PanelSearch" whose display property is set to none.
When i first load the page i have added the table in a placeholder which is inside another updatepanel (main panel). I have a search button inside the "PanelSearch" and when user clicks search i am retrieving data from database and binding it to the gridview.
The gridview has linkbutton as templatefield and OnCommand event.
When i click the linkbutton no event gets fired but my page refreshes and table inside "PanelSearch' disappears.
I don't know why.Can anyone please help me?
My markup is as below;
<asp:UpdatePanel ID="PanelPatientSearch" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table id="tablePatientSearch" clientidmode="Static" cellpadding="2" cellspacing="2" border="0"
style=" width:98%;display: table; margin-left: 10px;margin-right: 5px" runat="server" class="table">
<tr>
<th style="height:10px;width:100%"></th>
</tr>
<tr>
<td style="text-align: center">
<asp:Label ID="LabelSearchPatient" runat="server" CssClass="sectionHeaderForManagePages"
Text="Search Patient"></asp:Label>
</td>
</tr>
<tr>
<th style="height:10px;width:100%">
</th>
</tr>
<tr>
<td>
<table cellpadding="5" cellspacing="3" width="100%" >
<tr> <th colspan="4">
</th></tr>
<tr>
<th class="textCenterAlign" align="center" colspan="4"><asp:Label ID="labelSelectMessage" runat="server" Text="Search for Patient below or"></asp:Label>  
<asp:Button ID="buttonAddNewPatient" runat="server" CssClass="buttonLarge"
Text="Add Patient" onclick="buttonAddNewPatient_Click" CausesValidation="false" />
</th>
</tr>
<tr> <th colspan="4">
</th></tr>
<tr>
<td class="textRightAlign" width="25%">
<asp:Label ID="LabelPatientId" runat="server" Text="Patient ID" />
</td>
<td class="textLeftAlign" width="25%">
<asp:TextBox ID="textBoxID" runat="server" ClientIDMode="Static" CssClass="textBox" />
<asp:RequiredFieldValidator ID="RFVPatientID" runat="server" ControlToValidate="textBoxID"
CssClass="failureNotification" Display="None" ErrorMessage="Patient ID can not be blank"
SetFocusOnError="True" Width="0px"></asp:RequiredFieldValidator>
<cc1:ValidatorCalloutExtender ID="ValidatorCalloutExtender1" runat="server" CssClass="ajaxvalidatorPopup"
Enabled="True" TargetControlID="RFVPatientID">
</cc1:ValidatorCalloutExtender>
</td>
<td class="textRightAlign" width="25%">
<asp:Label ID="labelFirstName" runat="server" Text="First Name" />
</td>
<td class="textLeftAlign" width="25%">
<asp:TextBox ID="textBoxFirstName" runat="server" CssClass="textBox" />
</td>
</tr>
<tr>
<td class="textRightAlign" width="25%">
<asp:Label ID="labelLastName" runat="server" Text="Last Name" />
<br />
</td>
<td class="textLeftAlign" width="25%">
<asp:TextBox ID="textBoxLastName" runat="server" CssClass="textBox" />
<br />
</td>
<td class="textRightAlign" width="25%">
<asp:Label ID="labelDOB" runat="server" Text="Date of Birth" />
</td>
<td class="textLeftAlign" width="25%">
<asp:TextBox ID="textBoxDOB" runat="server" CssClass="textBox" />
<cc1:CalendarExtender ID="CalendarExtenderAppDate" runat="server" Enabled="True" Format="MM/dd/yyyy" TargetControlID="textBoxDOB">
</cc1:CalendarExtender>
</td>
</tr>
<tr>
<td class="textCenterAlign" colspan="4">
<br />
<asp:Button ID="buttonSearch" runat="server" CssClass="buttonLarge"
Text="Search" onclick="buttonSearch_Click" ClientIDMode="Static" CausesValidation="false" EnableViewState="false" />
<br />
<br />
</td>
</tr>
<tr>
<td colspan="4">
<br />
<asp:GridView ID="GridViewPatients1" runat="server" AutoGenerateColumns="False" CssClass="GridViewFullWidthCss"
EmptyDataText="No Patients are available" AllowPaging="True" OnRowCommand="GridViewPatients1_RowCommand"
AllowSorting="false" EnableViewState="true" ClientIDMode="Static" >
<Columns>
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:LinkButton ID="linkButtonSelect" runat="server" CommandName="Select" CommandArgument='<%#DataBinder.Eval(Container.DataItem,"PatientID") %>' CausesValidation="false" OnCommand="SelectPatient" Text="Select" EnableViewState="true"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="PatientID" HeaderText="Patient ID" SortExpression="PatientID">
<ItemStyle Width="20%" />
</asp:BoundField>
<asp:BoundField DataField="first_name" HeaderText="First Name" SortExpression="FirstName">
<ItemStyle Width="20%" />
</asp:BoundField>
<asp:BoundField DataField="last_name" HeaderText="Last Name" SortExpression="LastName">
<ItemStyle Width="20%" />
</asp:BoundField>
<asp:BoundField DataField="birth_date" HeaderText="Date of Birth" SortExpression="DOB">
<ItemStyle Width="20%" />
</asp:BoundField>
</Columns>
</asp:GridView>
</td>
</tr>
</table>
</td>
</tr>
</table>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="buttonSearch" EventName="click" />
</Triggers>
</asp:UpdatePanel>
And my code behind is like this
protected void SelectPatient(object sender, EventArgs e)
{
LinkButton lnkSelect = (LinkButton)sender;
Session["Selected_Patient_Id"] = lnkSelect.CommandArgument;
}
Generate RowCommand Event of GridView and use it like ..
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if(e.CommandName == "Select")
{
//write what you want to do
}
}
LinkButton click event doesn't fire because it is replace it's event on page load while you click on it.
You should use IsPostBack on Page_Load to avoid this. I think you are every time DataBind to GridView on page load.
So Ignore this and use code this way. It will be helpful for your problems.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
grid.DataSource = dsGrid;
grid.DataBind();
}
}
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.