<asp:HyperLink runat="server" ID="lnkAddJob" Text="Add New ADP Job Listing" NavigateUrl="~/ADPJobListingOp.aspx"></asp:HyperLink>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" DataKeyNames="JobID"
DataSourceID="ObjectDataSource1" OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:BoundField DataField="JobTitle" HeaderText="JobTitle"
SortExpression="JobTitle" />
<asp:TemplateField HeaderText="Category" SortExpression="CategoryID">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="ObjectDataSource2" DataTextField="CategoryName"
DataValueField="CategoryID" SelectedValue='<%# Bind("CategoryID") %>'>
</asp:DropDownList>
<asp:ObjectDataSource ID="ObjectDataSource2" runat="server"
SelectMethod="GetCategories" TypeName="ADPLibrary.BLL.JobCategoriesBLL"></asp:ObjectDataSource>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("CategoryName") %>'></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="URL" SortExpression="URL">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("URL") %>' Width="1050px"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("URL") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City">
<ControlStyle Width="100px" />
</asp:BoundField>
<asp:BoundField DataField="State" HeaderText="State" SortExpression="State">
<ControlStyle Width="20px" />
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="Country" HeaderText="Country" SortExpression="Country">
<ControlStyle Width="20px" />
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
DeleteMethod="DeleteJob"
SelectMethod="GetJobs" TypeName="ADPLibrary.BLL.JobBLL"
UpdateMethod="UpdateJob">
<DeleteParameters>
<asp:Parameter Name="jobID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="categoryID" Type="Int32" />
<asp:Parameter Name="jobTitle" Type="String" />
<asp:Parameter Name="url" Type="String" />
<asp:Parameter Name="city" Type="String" />
<asp:Parameter Name="state" Type="String" />
<asp:Parameter Name="country" Type="String" />
<asp:Parameter Name="jobID" Type="Int32" />
</UpdateParameters>
</asp:ObjectDataSource>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data;
using ADPLibrary.DAL;
using ADPLibrary.BLL;
public partial class Controls_ADPJobListingManager : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton lb = (LinkButton)e.Row.Cells[6].Controls[2];
if (lb.Text.ToLower() == "delete")
{
ADP.JobsRow job = (ADP.JobsRow)((DataRowView)e.Row.DataItem).Row;
lb.OnClientClick = string.Format("return confirm('Are you certain you want to delete {0} job listing?');", job.JobTitle.Replace("'", @"\'"));
}
}
}
}
|