| Author: Appukuttan 28 Aug 2008 | Member Level: Diamond | Rating: Points: 3 |
Hi..
<asp:GridView ID="gvCircularToall" runat="server" BorderWidth="0" BackColor="transparent" DataKeyNames="Id" BorderStyle="none" SkinID="gridviewSkin" EnableTheming="true" AllowPaging="true" PageSize="5" Width="100%" AutoGenerateColumns="false" OnRowCommand="gvCircularToall_RowCommand" OnPageIndexChanging="gvCircularToall_PageIndexChanging" > <Columns> <asp:TemplateField> <ItemTemplate> <asp:Image ID="Image21" runat="server" ImageUrl="~/Images/bullets.gif" /> </ItemTemplate> <ItemStyle HorizontalAlign="right" /> </asp:TemplateField> <asp:TemplateField> <HeaderTemplate> Circular To All</HeaderTemplate> <HeaderStyle CssClass="boxtext_blue_Heading" /> <HeaderStyle HorizontalAlign="left" /> <ItemTemplate> <asp:LinkButton ID="lnkCircular" runat="server" Text='<%#GetCircularName(Eval("Id").ToString())%>' CommandArgument='<%#Eval("Id")%>' CommandName="Circular" CssClass="boxtext_blue"></asp:LinkButton> </ItemTemplate> </asp:TemplateField> </Columns> <EmptyDataTemplate> <table align="left" class="boxbg"> <tr> <td> NO Circulation List</td> </tr> </table> </EmptyDataTemplate> </asp:GridView>
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 SourceEdge.BCL; using Tetragon.Spruce.Model; using System.Collections.Generic; using System.IO;
namespace VetCareWeb { public partial class CircularToAll : System.Web.UI.Page { #region"Global" string Filefullpath; string Script; #endregion
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindGrid(); } }
private void OpenFiles(string Filepath) { FileInfo file = new System.IO.FileInfo(Filepath); Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name); Response.WriteFile(Filepath); }
private void BindGrid() { List<AdminUtilityEntity> lstCircular = Database.SelectFrom(AdminUtilityEntity.Table) .Where(AdminUtilityEntity.Table.CircularToAllPath != null) .LoadList<AdminUtilityEntity>(); if (lstCircular != null) { if (lstCircular.Count > 0) { tblCircular.Visible = true; gvCircularToall.DataSource = lstCircular; gvCircularToall.DataBind(); } else { Script = VetCareUtilities.GetAlert("Files does not exists"); Page.ClientScript.RegisterStartupScript(typeof(Page), "Filedoesnotexists", Script); } } else { Script = VetCareUtilities.GetAlert("Files does not exists"); Page.ClientScript.RegisterStartupScript(typeof(Page), "Filedoesnotexists", Script); } }
protected string GetCircularName(string Id) { string sFilename = string.Empty; if (!string.IsNullOrEmpty(Id)) { AdminUtilityEntity objCircular = Database.SelectFrom(AdminUtilityEntity.Table) .Where(AdminUtilityEntity.Table.Id == Id) .LoadEntity<AdminUtilityEntity>(); if (objCircular != null) { if (!string.IsNullOrEmpty(objCircular.CircularToAllPath)) { string[] arrCircular = objCircular.CircularToAllPath.ToString().Split('/'); sFilename= arrCircular[1]; } } } return sFilename; }
protected void gvCircularToall_PageIndexChanging(object sender, GridViewPageEventArgs e) { gvCircularToall.PageIndex = e.NewPageIndex; BindGrid(); }
protected void gvCircularToall_RowCommand(object sender, GridViewCommandEventArgs e) { string strBulletinMDsPath = string.Empty; string sid = e.CommandArgument.ToString(); if (e.CommandName == "Circular") { AdminUtilityEntity objContent = Database.SelectFrom(AdminUtilityEntity.Table) .Where(AdminUtilityEntity.Table.Id == sid) .LoadEntity<AdminUtilityEntity>(); if (objContent != null) { if (!string.IsNullOrEmpty(objContent.CircularToAllPath)) { strBulletinMDsPath = objContent.CircularToAllPath.ToString(); } } if (System.IO.Directory.Exists(Server.MapPath("CircularToAll")) == true) { if (!string.IsNullOrEmpty(strBulletinMDsPath)) { Filefullpath = Server.MapPath(strBulletinMDsPath); OpenFiles(Filefullpath); } else { Script = VetCareUtilities.GetAlert("File does not exists"); Page.ClientScript.RegisterStartupScript(typeof(Page), "Filedoesnotexists", Script); } } else { Script = VetCareUtilities.GetAlert("File does not exists"); Page.ClientScript.RegisterStartupScript(typeof(Page), "Filedoesnotexists", Script); } } }
protected void gvCircularToall_RowDeleting(object sender, GridViewDeleteEventArgs e) { string RowId = gvCircularToall.DataKeys[e.RowIndex].Value.ToString();
AdminUtilityEntity objAdmin = Database.SelectFrom(AdminUtilityEntity.Table) .Where(AdminUtilityEntity.Table.Id == RowId) .LoadEntity<AdminUtilityEntity>(); if (objAdmin != null) { if (objAdmin.Delete()) { Script = VetCareUtilities.GetAlert("Circular to all details deleted successfully"); Page.ClientScript.RegisterStartupScript(typeof(Page), "deleted", Script); BindGrid(); } } } } }
|
| Author: Sidewinder2 28 Aug 2008 | Member Level: Gold | Rating: Points: 6 |
Hi,
Try This protected void Grid_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { if (((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))) {
e.Item.Cells[0].Attributes.Add("style", "cursor:hand"); LinkButton Link1 = (LinkButton)(e.Item.Cells[0].FindControl("Doc_Name")); string str = Link1.Text.ToString(); string path = Link1.Text.ToString(); lnk.NavigateUrl =Server.MapPath(path); e.Item.Cells[0].Controls.Add(lnk); lnk.Text = str;
} }
|