I have a FormView with an UpdateButton and a SqlDataSource which are below. My updatebutton always update the Sil table with the same values (the values at the first line of my gridview), I couldn't figure out why.
<asp:FormView ID="frm_Benefit" runat="server" DataKeyNames="ID" DataSourceID="sds_Benefits"
OnItemInserted="frm_Benefit_ItemInserted" OnItemUpdated="frm_Benefit_ItemUpdated">
<EditItemTemplate>
<table class="formview">
<tr>
<td>
Code:
</td>
<td>
<asp:TextBox ID="CodeTextBox" runat="server" Text='<%# Bind("Code") %>' />
</td>
</tr>
<tr>
<td>
Name:
</td>
<td>
<asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
</td>
</tr>
<tr>
<td>
HRName:
</td>
<td>
<asp:TextBox ID="HRNameTextBox" runat="server" Text='<%# Bind("HRName") %>' />
</td>
</tr>
<tr>
<td>
Description:
</td>
<td>
<asp:TextBox ID="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>'
TextMode="MultiLine" MaxLength="200" />
</td>
</tr>
<tr>
<td>
Associated Url:
</td>
<td>
<asp:TextBox ID="UrlTextBox" runat="server" Text='<%# Bind("Url") %>' MaxLength="100" />
</td>
</tr>
<tr>
<td>
BenefitType:
</td>
<td>
<asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="sds_BenefitTypes"
DataTextField="Name" DataValueField="ID" SelectedValue='<%# Bind("BenefitTypeID") %>'>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
Cost:
</td>
<td>
<asp:TextBox ID="CostTextBox" runat="server" Text='<%# Bind("Cost") %>' />
</td>
</tr>
<tr>
<td>
Cost Type:
</td>
<td>
<asp:DropDownList ID="CostTypeDropDown" runat="server" DataSourceID="sds_CostTypes"
DataTextField="Name" DataValueField="ID" SelectedValue='<%# Bind("CostTypeID") %>'>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
Quantity Type:
</td>
<td>
<asp:DropDownList ID="QuantityTypeDropDown" runat="server" DataSourceID="sds_QuantityTypes"
DataTextField="Name" DataValueField="ID" SelectedValue='<%# Bind("QuantityTypeID") %>'>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
Quantity Entry On Add:
</td>
<td>
<asp:CheckBox ID="QuantityEntryOnAddCheckBox" runat="server" Checked='<%# Bind("QuantityEntryOnAdd") %>' />
</td>
</tr>
<tr>
<td>
Quantity Entry On Remove:
</td>
<td>
<asp:CheckBox ID="QuantityEntryOnRemoveCheckBox" runat="server" Checked='<%# Bind("QuantityEntryOnRemove") %>' />
</td>
</tr>
<tr>
<td>
Bonus Ratio:
</td>
<td>
<asp:TextBox ID="BonusRatioTextBox" runat="server" Text='<%# Bind("BonusRatio") %>'></asp:TextBox>
</td>
</tr>
<tr>
<td>
ApplyIncomeTax:
</td>
<td>
<asp:CheckBox ID="ApplyIncomeTaxCheckBox" runat="server" Checked='<%# Bind("ApplyIncomeTax") %>' />
</td>
</tr>
<tr>
<td>
ApplyStampTax:
</td>
<td>
<asp:CheckBox ID="ApplyStampTaxCheckBox" runat="server" Checked='<%# Bind("ApplyStampTax") %>' />
</td>
</tr>
<tr>
<td class="style1">
ApplySocialSecurityTax:
</td>
<td class="style1">
<asp:CheckBox ID="ApplySocialSecurityTaxCheckBox" runat="server" Checked='<%# Bind("ApplySocialSecurityTax") %>' />
</td>
</tr>
<tr>
<td>
Applicable Location:
</td>
<td>
<asp:DropDownList ID="CostTypeDropDown1" runat="server" DataSourceID="sds_Locations"
DataTextField="Name" DataValueField="ID" SelectedValue='<%# Bind("ApplicableLocationID") %>'>
</asp:DropDownList>
</td>
</tr>
<tr>
<td colspan="2">
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
Text="Update" Style="display: none" />
<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False"
CommandName="Cancel" Text="Cancel" Style="display: none" />
</td>
</tr>
</table>
</EditItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="sds_Benefits" runat="server" ConnectionString="<%$ ConnectionStrings:ConnFlexibleBenefitsDB %>"
SelectCommand="SELECT * FROM [View_Benefits]"
UpdateCommand="UPDATE [Sil] SET [Code] = #Code, [HRName] = #HRName WHERE [Id] = #Id">
<UpdateParameters>
<asp:Parameter Name="Code" Type="String" />
<asp:Parameter Name="HRName" Type="String" />
<asp:Parameter Name="Id" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
And this is my gridview:
<asp:GridView ID="grd_Benefits" runat="server" AutoGenerateColumns="False" DataKeyNames="ID"
CssClass="gridTable" DataSourceID="sds_Benefits" OnRowCommand="grd_Benefits_RowCommand">
<RowStyle CssClass="gridRow" />
<FooterStyle CssClass="gridFooter" />
<SelectedRowStyle CssClass="gridSelectedRow" />
<HeaderStyle CssClass="gridHeader" />
<AlternatingRowStyle CssClass="gridAlternatingRow" />
<EmptyDataTemplate>
No records found.
</EmptyDataTemplate>
<Columns>
<asp:BoundField DataField="Code" HeaderText="Code" SortExpression="Code" />
<asp:BoundField DataField="HRName" HeaderText="HRName" SortExpression="HRName" />
<asp:TemplateField HeaderText="Benefit Type" SortExpression="BenefitType.Name">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("BenefitTypeName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Cost" HeaderText="Cost" SortExpression="Cost" />
<asp:TemplateField HeaderText="Cost Type">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("CostTypeName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Quantity Type">
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("QuantityTypeName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lbSelect" runat="server" CausesValidation="False" CommandName="ViewRecord"
Text="<img border='0' alt='Edit' src='../images/zoom.gif' />" CommandArgument='<%# Container.DataItemIndex %>'></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ShowHeader="False">
<HeaderTemplate>
<asp:LinkButton ID="lbInsert" runat="server" CausesValidation="false" CommandName="NewRecord"
Text="<img border='0' alt='New' src='../images/new.gif' />" CommandArgument='<%# Container.DataItemIndex %>'
ForeColor="White"></asp:LinkButton>
</HeaderTemplate>
<ItemTemplate>
<asp:LinkButton ID="lbEdit" runat="server" CausesValidation="False" CommandName="EditRecord"
Text="<img border='0' alt='Edit' src='../images/edit.gif' />" CommandArgument='<%# Container.DataItemIndex %>'></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
RowCommand:
protected void grd_Benefits_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "ViewRecord")
{
grd_Benefits.SelectedIndex = int.Parse(e.CommandArgument.ToString());
frm_Benefit.ChangeMode(FormViewMode.ReadOnly);
Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowFormViewView", "<script type=\"text/javascript\">showFormViewView();</script>");
}
else if (e.CommandName == "NewRecord")
{
frm_Benefit.ChangeMode(FormViewMode.Insert);
Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowFormViewInsert", "<script type=\"text/javascript\">showFormViewInsert();</script>");
}
else if (e.CommandName == "EditRecord")
{
grd_Benefits.SelectedIndex = int.Parse(e.CommandArgument.ToString());
frm_Benefit.ChangeMode(FormViewMode.Edit);
Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowFormViewEdit", "<script type=\"text/javascript\">showFormViewEdit();</script>");
}
}
Seeing your Markups and taking it as it is, the issue is with the FormView.
You have not set the AllowPaging="true" for FormView. So every time the FormView displays, it will just Display only the First Row of all the data records retrieved.
[ Note that Form View displays only one single record at a time ].
So every time you are selecting 'Edit' in Form View, you are actually editing the First record only ( which is indeed the First row of GridView).
Set the AllowPaging property to true for FormView.
<asp:FormView ID="frm_Benefit" runat="server" DataKeyNames="CustomerID"
DataSourceID="sds_Benefits" OnItemUpdated="frm_Benefit_ItemUpdated"
AllowPaging="true">
After that using the Paging index, navigate to any record you want to change and edit it as seen below.
Related
I have a ListView in .NET that is hooked up to various CRUD methods, the select method that accepts a value doesn't seem to be working. The Data Source is supposed to be taking the value from a drop down list control, taking the selected value. when I do the configure data source method in visual studio, I select this method for my select operation:
EntReqList_byID(Int32 programID), returns List<EntranceRequirementInfo>
Then when I define parameters in the next part of the wizard, I pick control as a parameter source, with the control ID set to CertificateList, which shows the programID as the parameter from CertificateList.SelectedValue.
When I run the page, and select an item from the CertificateList, and click "Show Program", all my data is pulled except for that in the list view. My code is as follows:
The top of my page:
Please select the program credential type:
<asp:DropDownList ID="InitialCredential" runat="server" AutoPostBack="True" OnSelectedIndexChanged="InitialCredential_SelectedIndexChanged">
<asp:ListItem>[Select]</asp:ListItem>
<asp:ListItem>Certificate</asp:ListItem>
<asp:ListItem>Diploma</asp:ListItem>
<asp:ListItem>Degree</asp:ListItem>
</asp:DropDownList>
</p>
<p>
Please select a program:
<asp:DropDownList ID="CertificateList" runat="server" DataSourceID="CertificateODS" DataTextField="ProgramName" DataValueField="ProgramID" Visible="false"></asp:DropDownList>
<asp:DropDownList ID="DiplomaList" runat="server" DataSourceID="DiplomaListODS" DataTextField="ProgramName" DataValueField="ProgramID" Visible="false"></asp:DropDownList>
<asp:DropDownList ID="DegreeList" runat="server" DataSourceID="DegreeListODS" DataTextField="DegreeName" DataValueField="DegreeID" Visible="false"></asp:DropDownList>
</p>
<p>
<asp:LinkButton ID="ShowUpdateFields" runat="server" OnClick="ShowUpdateFields_Click">Show Program</asp:LinkButton>
</p>
My ListView:
<asp:ListView ID="EntReqListView" runat="server" DataSourceID="EntranceReqODS" InsertItemPosition="LastItem">
<AlternatingItemTemplate>
<tr style="">
<td>
<asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" />
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
</td>
<td>
<asp:Label ID="ProgramIDLabel" runat="server" Text='<%# Eval("ProgramID") %>' />
</td>
<td>
<asp:Label ID="CourseIDLabel" runat="server" Text='<%# Eval("CourseID") %>' />
</td>
<td>
<asp:Label ID="CourseNameLabel" runat="server" Text='<%# Eval("CourseName") %>' />
</td>
<td>
<asp:Label ID="MarkLabel" runat="server" Text='<%# Eval("Mark") %>' />
</td>
</tr>
</AlternatingItemTemplate>
<EditItemTemplate>
<tr style="">
<td>
<asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
</td>
<td>
<asp:TextBox ID="ProgramIDTextBox" runat="server" Text='<%# Bind("ProgramID") %>' />
</td>
<td>
<asp:TextBox ID="CourseIDTextBox" runat="server" Text='<%# Bind("CourseID") %>' />
</td>
<td>
<asp:TextBox ID="CourseNameTextBox" runat="server" Text='<%# Bind("CourseName") %>' />
</td>
<td>
<asp:TextBox ID="MarkTextBox" runat="server" Text='<%# Bind("Mark") %>' />
</td>
</tr>
</EditItemTemplate>
<EmptyDataTemplate>
<table runat="server" style="">
<tr>
<td>No data was returned.</td>
</tr>
</table>
</EmptyDataTemplate>
<InsertItemTemplate>
<tr style="">
<td>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
</td>
<td>
<asp:TextBox ID="ProgramIDTextBox" runat="server" Text='<%# Bind("ProgramID") %>' />
</td>
<td>
<asp:TextBox ID="CourseIDTextBox" runat="server" Text='<%# Bind("CourseID") %>' />
</td>
<td>
<asp:TextBox ID="CourseNameTextBox" runat="server" Text='<%# Bind("CourseName") %>' />
</td>
<td>
<asp:TextBox ID="MarkTextBox" runat="server" Text='<%# Bind("Mark") %>' />
</td>
</tr>
</InsertItemTemplate>
<ItemTemplate>
<tr style="">
<td>
<asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" />
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
</td>
<td>
<asp:Label ID="ProgramIDLabel" runat="server" Text='<%# Eval("ProgramID") %>' />
</td>
<td>
<asp:Label ID="CourseIDLabel" runat="server" Text='<%# Eval("CourseID") %>' />
</td>
<td>
<asp:Label ID="CourseNameLabel" runat="server" Text='<%# Eval("CourseName") %>' />
</td>
<td>
<asp:Label ID="MarkLabel" runat="server" Text='<%# Eval("Mark") %>' />
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table id="itemPlaceholderContainer" runat="server" border="0" style="">
<tr runat="server" style="">
<th runat="server"></th>
<th runat="server">ProgramID</th>
<th runat="server">CourseID</th>
<th runat="server">CourseName</th>
<th runat="server">Mark</th>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server" style="">
<asp:DataPager ID="DataPager1" runat="server">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowLastPageButton="True" />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</LayoutTemplate>
<SelectedItemTemplate>
<tr style="">
<td>
<asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" />
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
</td>
<td>
<asp:Label ID="ProgramIDLabel" runat="server" Text='<%# Eval("ProgramID") %>' />
</td>
<td>
<asp:Label ID="CourseIDLabel" runat="server" Text='<%# Eval("CourseID") %>' />
</td>
<td>
<asp:Label ID="CourseNameLabel" runat="server" Text='<%# Eval("CourseName") %>' />
</td>
<td>
<asp:Label ID="MarkLabel" runat="server" Text='<%# Eval("Mark") %>' />
</td>
</tr>
</SelectedItemTemplate>
</asp:ListView>
My Code behind:
protected void InitialCredential_SelectedIndexChanged(object sender, EventArgs e)
{
//display programs DDL based on credential choice
if(InitialCredential.SelectedValue == "Certificate")
{
CertificateList.Visible = true;
DiplomaList.Visible = false;
DegreeList.Visible = false;
}
else if (InitialCredential.SelectedValue == "Diploma")
{
CertificateList.Visible = false;
DiplomaList.Visible = true;
DegreeList.Visible = false;
}
else if (InitialCredential.SelectedValue == "Degree")
{
CertificateList.Visible = false;
DiplomaList.Visible = false;
DegreeList.Visible = true;
}
else
{
CertificateList.Visible = false;
DiplomaList.Visible = false;
DegreeList.Visible = false;
}
}
protected void CredentialType_SelectedIndexChanged(object sender, EventArgs e)
{
switch (CredentialType.SelectedValue)
{
case "Diploma":
{
entrance_req.Visible = true;
degree_link.Visible = false;
degree_pathways.Visible = true;
}
break;
case "Certificate":
{
entrance_req.Visible = true;
degree_link.Visible = false;
degree_pathways.Visible = false;
}
break;
case "Degree":
{
entrance_req.Visible = false;
degree_link.Visible = true;
degree_pathways.Visible = false;
}
break;
default:
{
entrance_req.Visible = false;
degree_link.Visible = false;
degree_pathways.Visible = false;
}
break;
}
}
protected void ShowUpdateFields_Click(object sender, EventArgs e)
{
show_update_form.Visible = true;
if (InitialCredential.SelectedValue == "Certificate")
{
DiplomaCertificate certificate = new DiplomaCertificate();
PathwaysController controller = new PathwaysController();
certificate = controller.CertificateProgram_byID(int.Parse(CertificateList.SelectedValue));
ProgramName.Text = certificate.ProgramName;
CategoryList.SelectedValue = certificate.CategoryID.ToString();
CredentialType.SelectedValue = "Certificate";
ProgramLength.Text = certificate.ProgramLength;
ProgramLink.Text = certificate.ProgramLink;
Activated.Checked = certificate.Activated;
WorkOutdoors.Checked = certificate.WorkOutdoors;
ShiftWork.Checked = certificate.ShiftWork;
Travel.Checked = certificate.WorkTravel;
}
}
Is there something I am missing to make it get the programID, and populate the data?
I have db which contains products with columns: image1, image2, image3. I'm displaying this datalist and only first picture occurs there. On the others images I see that redirection is fine, but it isn't showing them up.
Markup:
<asp:DataList ID="DataList2" runat="server" DataKeyField="ID" DataSourceID="SqlDataSource1">
<ItemTemplate>
<table>
<tr>
<td rowspan="2">
<asp:HyperLink ID="HyperLink3" runat="server" ImageUrl='<%# Eval("image1", "{0}") %>' data-lightbox="imageset" Height="150px" Width="150px" ImageHeight="150px" ImageWidth="150px" NavigateUrl='<%# Eval("image1", "{0}") %>'></asp:HyperLink>
</td>
<td width="600px"><asp:Label ID="nazwaLabel" runat="server" Text='<%# Eval("nazwa") %>' CssClass="produktNazwa" />
</tr>
<tr>
<td><asp:Label ID="cenaLabel" runat="server" Text='<%# Eval("cena", "{0} PLN") %>' CssClass="produktCena" /> </td>
</tr>
<tr>
<td>
<asp:HyperLink ID="HyperLink4" runat="server" ImageUrl='<%# Eval("image2", "{0}") %>' data-lightbox="imageset" Height="150px" Width="150px" ImageHeight="150px" ImageWidth="150px" NavigateUrl='<%# Eval("image2", "{0}") %>'></asp:HyperLink>
</td>
<td><asp:Label ID="opisLabel" runat="server" Text='<%# Eval("opis") %>' CssClass="produktOpis" /></td>
</tr>
<tr>
<td>
<asp:HyperLink ID="HyperLink5" runat="server" ImageUrl='<%# Eval("image3", "{0}") %>' data-lightbox="imageset" Height="150px" Width="150px" ImageHeight="150px" ImageWidth="150px" NavigateUrl='<%# Eval("image3", "{0}") %>'></asp:HyperLink>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [Produkty] WHERE ([ID] = #ID)">
<SelectParameters>
<asp:ControlParameter ControlID="Label1" Name="ID" PropertyName="Text" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
Any ideas?
I have the following code for my Edit Stored Procedure:
CREATE PROCEDURE [dbo].[sp_EditDates]
#ID int,
#PublishYear int,
#PublishMonth int,
#PayDte varchar(200),
#PublishDte varchar(200)
AS
BEGIN
-- Insert statements for procedure here
UPDATE PaymentAndPublishingDates SET PublishYear = #PublishYear, PublishMonth = #PublishMonth, PayDte = #PayDte, PublishDte = #PublishDte
WHERE ID=#ID;
END
And the following for my Select stored procedure:
CREATE PROCEDURE [dbo].[sp_RetrieveAllDates]
AS BEGIN SELECT DISTINCT
PaymentAndPublishingDates.ID, PaymentAndPublishingDates.PublishYear,
PaymentAndPublishingDates.PublishMonth,
CONVERT(VARCHAR,PaymentAndPublishingDates.PayDte,106)AS PayDate,
CONVERT(VARCHAR,PaymentAndPublishingDates.PublishDte,120) AS PublishDate
FROM PaymentAndPublishingDates
END
And I have a datasource like this:
<asp:ListView ID="ListView1" runat="server" DataSourceID="Payment_Dates"
InsertItemPosition="LastItem">
<AlternatingItemTemplate>
<tr style="background-color:#FFF8DC;">
<td>
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
</td>
<td>
<asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' />
</td>
<td>
<asp:Label ID="PublishYearLabel" runat="server"
Text='<%# Eval("PublishYear") %>' />
</td>
<td>
<asp:Label ID="PublishMonthLabel" runat="server"
Text='<%# Eval("PublishMonth") %>' />
</td>
<td>
<asp:Label ID="PayDateLabel" runat="server" Text='<%# Eval("PayDate") %>' />
</td>
<td>
<asp:Label ID="PublishDateLabel" runat="server"
Text='<%# Eval("PublishDate") %>' />
</td>
</tr>
</AlternatingItemTemplate>
<EditItemTemplate>
<tr style="background-color:#008A8C;color: #FFFFFF;">
<td>
<asp:Button ID="UpdateButton" runat="server" CommandName="Update"
Text="Update" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel"
Text="Cancel" />
</td>
<td>
<asp:Label ID="IDLabel1" runat="server" Text='<%# Eval("ID") %>' />
</td>
<td>
<asp:TextBox ID="PublishYearTextBox" runat="server"
Text='<%# Bind("PublishYear") %>' />
</td>
<td>
<asp:TextBox ID="PublishMonthTextBox" runat="server"
Text='<%# Bind("PublishMonth") %>' />
</td>
<td>
<asp:TextBox ID="PayDateTextBox" runat="server" Text='<%# Bind("PayDate") %>' />
</td>
<td>
<asp:TextBox ID="PublishDateTextBox" runat="server"
Text='<%# Bind("PublishDate") %>' />
</td>
</tr>
</EditItemTemplate>
<EmptyDataTemplate>
<table runat="server"
style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;">
<tr>
<td>
No data was returned.</td>
</tr>
</table>
</EmptyDataTemplate>
<InsertItemTemplate>
<tr style="">
<td>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert"
Text="Insert" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel"
Text="Clear" />
</td>
<td>
</td>
<td>
<asp:TextBox ID="PublishYearTextBox" runat="server"
Text='<%# Bind("PublishYear") %>' />
</td>
<td>
<asp:TextBox ID="PublishMonthTextBox" runat="server"
Text='<%# Bind("PublishMonth") %>' />
</td>
<td>
<asp:TextBox ID="PayDateTextBox" runat="server" Text='<%# Bind("PayDate") %>' />
</td>
<td>
<asp:TextBox ID="PublishDateTextBox" runat="server"
Text='<%# Bind("PublishDate") %>' />
</td>
</tr>
</InsertItemTemplate>
<ItemTemplate>
<tr style="background-color:#DCDCDC;color: #000000;">
<td>
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
</td>
<td>
<asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' />
</td>
<td>
<asp:Label ID="PublishYearLabel" runat="server"
Text='<%# Eval("PublishYear") %>' />
</td>
<td>
<asp:Label ID="PublishMonthLabel" runat="server"
Text='<%# Eval("PublishMonth") %>' />
</td>
<td>
<asp:Label ID="PayDateLabel" runat="server" Text='<%# Eval("PayDate") %>' />
</td>
<td>
<asp:Label ID="PublishDateLabel" runat="server"
Text='<%# Eval("PublishDate") %>' />
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table ID="itemPlaceholderContainer" runat="server" border="1"
style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;">
<tr runat="server" style="background-color:#DCDCDC;color: #000000;">
<th runat="server">
</th>
<th runat="server">
ID</th>
<th runat="server">
PublishYear</th>
<th runat="server">
PublishMonth</th>
<th runat="server">
PayDate</th>
<th runat="server">
PublishDate</th>
</tr>
<tr ID="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server"
style="text-align: center;background-color: #CCCCCC;font-family: Verdana, Arial, Helvetica, sans-serif;color: #000000;">
</td>
</tr>
</table>
</LayoutTemplate>
<SelectedItemTemplate>
<tr style="background-color:#008A8C;font-weight: bold;color: #FFFFFF;">
<td>
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
</td>
<td>
<asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' />
</td>
<td>
<asp:Label ID="PublishYearLabel" runat="server"
Text='<%# Eval("PublishYear") %>' />
</td>
<td>
<asp:Label ID="PublishMonthLabel" runat="server"
Text='<%# Eval("PublishMonth") %>' />
</td>
<td>
<asp:Label ID="PayDateLabel" runat="server" Text='<%# Eval("PayDate") %>' />
</td>
<td>
<asp:Label ID="PublishDateLabel" runat="server"
Text='<%# Eval("PublishDate") %>' />
</td>
</tr>
</SelectedItemTemplate>
</asp:ListView>
<asp:SqlDataSource ID="Payment_Dates" runat="server"
ConnectionString="<%$ ConnectionStrings:TUT_ElectronicPayslipsConnectionString %>"
InsertCommand="sp_CapturePayDate" InsertCommandType="StoredProcedure"
SelectCommand="sp_RetrieveAllDates" SelectCommandType="StoredProcedure"
UpdateCommand="sp_EditDates" UpdateCommandType="StoredProcedure">
<InsertParameters>
<asp:Parameter Name="PublishYear" Type="Int32" />
<asp:Parameter Name="PublishMonth" Type="Int32" />
<asp:Parameter Name="PayDte" Type="String" />
<asp:Parameter Name="PublishDte" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="ID" Type="Int32" />
<asp:Parameter Name="PublishYear" Type="Int32" />
<asp:Parameter Name="PublishMonth" Type="Int32" />
<asp:Parameter Name="PayDte" Type="String" />
<asp:Parameter Name="PublishDte" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
The data displays fine but when I try to edit fields I get this error "Procedure or function sp_EditDates has too many arguments specified".
Please Help
I have a datalist filled with items from database and each item has an image button onclick of which I want to show a modalpopup containing the Description of the particular Item. Below is what I have dine so far but fail:
<asp:DataList ID="DataList1" runat="server" RepeatColumns="3" RepeatDirection="Horizontal" Width="100%">
<ItemTemplate>
<table width="228px">
<tr>
<td width="20px" > </td>
<td width="160px" align="center">
<asp:Label ID="pID" runat="server" Visible="false" Text='<%# Eval("id") %>'></asp:Label><asp:Label ID="Label1" runat="server" Text='<%# Eval("ProductName") %>' Font-Size="8pt" ForeColor="#336699" Width="100%" />
</td>
<td align="right">
<asp:ImageButton ID="SpecificBtn" ImageUrl="images/SmallCallout.png" OnClick="SpecificBtn_Click" CommandArgument='<%# Eval("Id") %>' runat="server" />
<ajaxToolkit:ModalPopupExtender ID="mdl" runat="server" PopupControlID="pnl" TargetControlID="SpecificBtn" Enabled="True" CancelControlID="btn" DropShadow="true" Drag="True" ></ajaxToolkit:ModalPopupExtender>
</td>
</tr>
</table>
<asp:Image ID="Image1" runat="server" ImageUrl='<%# "GetImage.aspx?id=" + Eval("id") %>' /><br />
<table align="center" style="position:relative; left:2px;" cellspacing="0" cellpadding = "0" width="228px">
<tr>
<td style="background-color:Black;" colspan=2>
<div >
<asp:Image ID="Image2" ImageUrl="/images/cart.png" runat="server" />
<asp:Button CommandName="AddToCart" CssClass="anchor" OnClick="addProduct" CausesValidation="false" CommandArgument='<%# Eval("Id") %>' ID="addToHire" runat="server" Text=" Add To Cart " BackColor="Black" BorderColor="Black" BorderStyle="None" ForeColor="#F8CD20" Height="24" Font-Bold="true" Font-Size="10" />
</div>
</td>
</tr>
</table>
<br /><br />
</ItemTemplate>
<ItemStyle CssClass="dataListItemStyle" HorizontalAlign="Center" VerticalAlign="Top" />
</asp:DataList>
<asp:Panel ID="pnl" runat="server" visible="false" Width="300px" Height="300px" BackColor="red">
<asp:Label ID="Label2" runat="server" Text="Specification"></asp:Label>
<asp:Label ID="Label3" runat="server" Text='<%# Eval("Specification") %>'></asp:Label>
<asp:Button ID="btn" runat="server" Text="cancel" />
</asp:Panel>
Code behind:
protected void SpecificBtn_Click(object sender, EventArgs e)
{
DataListItem dli = (DataListItem)((ImageButton)sender).Parent;
ModalPopupExtender ModalPopupExtender2 = (ModalPopupExtender)dli.FindControl("mdl");
pnl.Visible = true;
ModalPopupExtender2.Show();
}
Can somebody tell me how to acheive this and where I went wrong. Thanks.
use jquery..
function onimagebuttonclick()
{
$find('BehaviorIDofmodelpopupextender').show();
}
i hope this solves your problem..
I'm trying to filter a listview, using a textbox control via an object datasource. However when I add anything nothing happens . I've created something similar before and all the codes pretty much the same. anyone got any ideas' what I'm missing ??
<asp:TextBox ID="namefilter" runat="server" />
<asp:Button ID="button1" runat="server" />
<asp:ListView DataSourceID="DataSource" ID="ListView1" runat="server" DataKeyNames="ID" InsertItemPosition="LastItem">
<LayoutTemplate>
<table cellspacing="1" cellpadding="1" border="0" bgcolor="#6699cc" width="100%" >
<tr>
<th> </th>
<th> </th>
<th><span class="Caption1">Name</span></th>
<th><span class="Caption1">Phone</span></th>
</tr>
<tr id="itemPlaceholder" runat="server" />
</table>
</LayoutTemplate>
<ItemTemplate>
<tr style="background-color: White;" >
<td><asp:LinkButton ID="btnEdit" runat="server" Text="Edit" CommandName="Edit" /></td>
<td><asp:LinkButton ID="btnDelete" runat="server" Text="Delete" CommandName="Delete" /></td>
<td align="center"><%# DataBinder.Eval(Container, "DataItem.Name")%> </td>
<td align="center"><%# DataBinder.Eval(Container, "DataItem.Phone")%> </td>
</tr>
</ItemTemplate>
<EditItemTemplate>
<tr style="background-color: White;" >
<td><asp:LinkButton ID="btnSave" runat="server" Text="Save" CommandName="Update" /></td>
<td><asp:LinkButton ID="btnCancel" runat="server" Text="Cancel" CommandName="Cancel" /></td>
<td><asp:TextBox ID="EditName" runat="server" Text='<%# Bind("Name") %>' /></td>
<td><asp:TextBox ID="EditPhone" runat="server" Text='<%# Bind("Phone") %>' /></td>
</tr>
</EditItemTemplate>
<InsertItemTemplate>
<tr bgcolor="#6699cc" >
<td><asp:LinkButton ID="InsertButton" CommandName="Insert" runat="server" Text="Insert" ValidationGroup="add" CssClass="Caption1" /> </td>
<td><asp:LinkButton ID="CancelButton" CommandName="Cancel" runat="server" Text="Cancel" CausesValidation="false" CssClass="Caption1" /></td>
<td> <asp:TextBox ID="InsertName" runat="server" Text='<%# Bind("Name") %>' ValidationGroup="insert" /> </td>
<td><asp:TextBox ID="InsertPhone" runat="server" Text='<%# Bind("Phone") %>' /> </td>
</InsertItemTemplate>
</asp:ListView>
<asp:LinqDataSource
ContextTypeName="assembly"
EnableUpdate="true"
EnableDelete="true"
EnableInsert="true"
ID="DataSource"
OrderBy="Email desc"
runat="server"
TableName="Contacts"
AutoSort="true"
>
<whereParameters>
<asp:ControlParameter ControlID="emailfilter" Name="Email" PropertyName="Text" Type="String" ConvertEmptyStringToNull="false" />
</whereParameters>
</asp:LinqDataSource>
d'oh, forgot to add the sort by where clause in the linqdatasource.. 3 hours wasted!!!
<asp:LinqDataSource
ContextTypeName="Immediacy.VS.Plugins.DBML.VisitScotlandDataContext"
EnableUpdate="true"
EnableDelete="true"
EnableInsert="true"
ID="DataSource"
OrderBy="Email desc"
runat="server"
TableName="Contacts"
AutoSort="true"
Where='(#Email == null) || (Email == #Email)'
>