It is showing hyperlink column link in grid properly, but as column text it is showing full hyperlink url rather then only value of ID, can anyone tell whats wrong I am doing here. Secondly, I also want that if someone click on hyperlink text, it should open in new window.
How can i create a hyperlink to Grid view column, when i click this column it should open Word documentnt.Each Column row values does have seperate information.
I would like to add a column in my datagridview that takes the value from the database and asigns it to the text of a linkbutton or make it a hyperlink. i know how to handle getting the value from the row but dont know how to make a value a link, or set the text to a link button
I have a Gridview with autogenerated columns since the query structure keeps changing depending the dropdown list.
However for Jan-10 etc column I want to format it to #,##0 etc. I use Dataformatstring when hard code the column but for autogenerated column, what can I do ?
I know one way is in script databound event make it that format whenever header = Jan-10 etc. What should be the code?
I want if the header of a particular column contains a word "S", the header and row turns red. I used following code to make header red and it works fine. How to make it such that the rows also turn red if condition is met ? I cannot hardcode in columns since the Gridview is autogenerate colums as data structure keeps changing.
Protected Sub GridView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs)Dim HeaderRow As GridViewRow = GridView1.HeaderRowFor Each c As TableCell In HeaderRow.CellsIf c.Text.EndsWith("S") Then c.BackColor = Drawing.Color.OrangeRed End If Next End Sub
My grid is not binding properly in IE and I found the reason why it is not working. one of my column value in grid is showing video and database value is
i have a grid view with some coulmns like Name,Phone no etc with Edit,Delete column in grid view. I click a row in grid view to Edit,it goes another page where i can edit all fields .Once i update i redirect the page to gridview. I want the grid view to remain in that particular page say 4 of the grid view
I am using a datalist to display data from a database.Except for 1 column all the other column values are getting repeated so I am hiding all the other column values when the datalist repeats itself.However, the unique column value is not getting rendered properly because there are many line breaks in between.I am not using any web control to display the static text and I am not sure if that would help.I just want to improve the final display so that the datalist looks consistent.I am attaching my code.
whn i click edit button on grid before sorting on any column it is working properly...but once i click on any column for sorting n thn click on edit then the rows get sorted again and edit is set on some other row... plz help me...herez my code..
I've created a simple (or what I thought was simple!) search form using Razor, MVC3 and the webgrid from the web helpers. I enabled paging, used a great article I found here to get that working... or so I thought. Basically what happens is that when I click the page buttons at the bottom of the grid it does something that I didn't expect, and creates a JSON object, then the browser prompts me to try and save it, and not as I expected to refill the grid. I can't see what I'm doing wrong, and before I break my monitor by throwing it onto the railway line!
[Code]....
My jQuery code
[Code]....
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using MvcApplication1.Models; using System.Configuration; using System.Web.Helpers; namespace MvcApplication1.Controllers { public class SearchController : Controller { // // GET: /Search/ Entities t = new Entities(ConfigurationManager.ConnectionStrings["Entities"].ConnectionString); public ActionResult Details(int id) { Tender_Question q = (from x in t.Tender_Questions where x.Unique_ID_number == id select x).SingleOrDefault(); Customer c = (from cu in t.Customers where cu.CustomersID == q.Company select cu).SingleOrDefault(); ViewBag.Customers = c.CompanyName; Panel_type pan = (from pa in t.Panel_types where pa.ID == q.Panel_type select pa).SingleOrDefault(); ViewBag.Panel = pan.Panel_type1; return View(q); } [HttpGet] public ActionResult Edit(int id) { Tender_Question q = (from x in t.Tender_Questions where x.Unique_ID_number == id select x).SingleOrDefault(); List<Customer> c = (from cu in t.Customers select cu).ToList(); ViewBag.Customers = c; return View(q); } [HttpPost] public ActionResult Edit(Tender_Question model) { if (ModelState.IsValid) { Tender_Question q = (from x in t.Tender_Questions where x.Unique_ID_number == model.Unique_ID_number select x).SingleOrDefault(); q.Answer = model.Answer; q.Company = model.Company; q.Customer = model.Customer; q.Date = model.Date; q.Page_Question_Ref = model.Page_Question_Ref; q.Panel_type = model.Panel_type; q.Question = model.Question; q.Type_of_tender = model.Type_of_tender; //add update code t.SaveChanges(); return RedirectToAction("Index"); } else { return View(model); } } [HttpGet] public ActionResult Search(int? page) { if (page.HasValue) { return RedirectToAction("EfficientPaging", new { page = page }); } else { return View(); } } [HttpPost] public ActionResult Search(int? page, FormCollection collection) { TempData.Clear(); IEnumerable<Tender_Question> q = getSearch(collection); TempData.Add("Results", q); return View(q); } private IEnumerable<Tender_Question> getSearch(FormCollection collection) { string question; string answer; IEnumerable<Tender_Question> q = t.Tender_Questions; question = collection["Question"]; answer = collection["Answer"]; if (!string.IsNullOrEmpty(question)) { if (question.EndsWith(",")) { question = question.Substring(0, question.Length - 1); } if (question.Length > 0) { if (question.Contains(",")) { string[] questioned = question.Split(','); foreach (string s in questioned) { q = q.Where(m => m.Question.Contains(s)); } } else { q = q.Where(m => m.Question.Contains(question)); } } } if (!string.IsNullOrEmpty(answer)) { if (answer.EndsWith(",")) { answer = answer.Substring(0, answer.Length - 1); } if (answer.Length > 0) { if (answer.Contains(",")) { string[] answered = answer.Split(','); foreach (string s in answered) { q = q.Where(m => m.Answer.Contains(s)); } } else { q = q.Where(m => m.Answer.Contains(answer)); } } } return q; } [HttpGet] public ActionResult EfficientPaging(int? page) { IEnumerable<Tender_Question> q = (IEnumerable<Tender_Question>)TempData["Results"]; int skip = page.HasValue ? page.Value - 1 : 0; q = q.OrderBy(o => o.Unique_ID_number).Skip(skip * 10).Take(10).ToList(); var grid = new WebGrid(q); var column = new WebGridColumn(); column.CanSort = false; column.ColumnName = "Unique_ID_number"; column.Header = "Edit"; column.Format = (item) => { return new HtmlString("<a href="/Home/Edit/" + column.ColumnName + "">Edit</a> "); }; var detcolumn = new WebGridColumn(); detcolumn.CanSort = false; detcolumn.ColumnName = "Unique_ID_number"; detcolumn.Header = "Details"; detcolumn.Format = (item) => { return new HtmlString("<a href="/Home/Details/" + column.ColumnName + "">Details</a> "); }; var htmlString = grid.GetHtml(htmlAttributes: new { id = "DataTable" }, columns: grid.Columns( column, detcolumn, grid.Column("Question"), grid.Column("Answer"), grid.Column("Company"), grid.Column(columnName: "Type_of_tender", header: "Type of Tender"), grid.Column(columnName: "Panel_type", header: "Panel type"), grid.Column(columnName: "Page_Question_Ref", header: "Page Question Ref"), grid.Column("Date") )); return Json(new { Data = htmlString.ToHtmlString(), Count =q.Count() / 10 }, JsonRequestBehavior.AllowGet); } } }
I'm using the "Reponse.ContentType Method" for exporting from an ASP.NET page to excel using code similar to this:
[Code]....
That isn't my exact code since my code is in C# but otherwise basically the same. It works fine but when I open the file in Excel everything is formatted with the "General" data type. It doesn't matter if its a string, a number or a currency. I would like to be able to define how each column is formatted so that Excel displays the data properly with minimal if not any work from the user. I know the sw.ToString above is simply an html table that is in string form. Do I have to parse that string and add in something to format each cell or can I do something with the DataGrid object or something completely different? This seems like it would be a common problem or desire but I can't find much of anything on it anywhere.
I have a hyperlink column in a datagrid that uses DataNavigateUrlFormatString to open a popup window via javascript. I am trying to get two variables from a sql to show in the query string for the popup window. I am able to pass the sessionstart date which is ={0} but the other those two variables in the javascript I am not sure how to pass. The two are school_id and program_id in the select statement below:
strsql = "select count(z.iIndividualid) as enrolled,session_id,school_id as SchoolId,program_id as ProgramId,convert(nvarchar(10),session_start_date,101) as SessionStartDate, session_class_size as SessionClassSize from dbo.cnSchoolProgramSessions cn with (nolock) left join customerproductdetail cpd on cn.session_start_date = cpd.dtdate1 left join customerproduct cp on cpd.iproductid=cp.iproductid and cp.iSiteId = cpd.iSiteId and cpd.tiRecordStatus = cp.tiRecordStatus left join individual z on z.iIndividualId = cp.iOwnerId And z.tiRecordStatus = cp.tiRecordStatus where record_status = 1 and school_id = '" & iSchool & "' and program_id = '" & iProgram & "' group by session_id, school_id, program_id,session_start_date,session_class_size"
[Code]....
What do I need to pass in the hyperlink column to get the proper? Hopefully this makes sense to someone
I have a HyperLink column in a gridview that when clicked should navigate the user to another page. I pass parameters to the page using a querystring. i want to know the basic code in C# to pass parameter to other using querystring
Is there a way to make a hyperlink column in datagrid on the fly... I have a search page and would like the user to be able to click a button to few full contents about the item for editing, etc.
BroughtForward and Pending both columns contain hyperlink values. When we click the values then another page opens with the details. I don't want to open another page if user click 0 in any column or in other words how to remove hyperlink if there is 0 in any cell?
I'm a bit new to this game. I'm trying to build a web page that simply scans a directory in the server and creates a web page with links to the files in that directory - sounds simple and should be easy to do !So I have a bit of code that reads the myDocuments folder in my web site and then populates a grid view hyperlink column with the filenames in the folder - wow it works !The only thing I am struggling with now is getting the hyperlink correct within the GridView so that the user goes to the actual document.So my code behind is;
[Code]....
which reads the file info in the directory myDocuments and binds the info to a datasource.So now I'm using that datasource to display the filenames in a gridview so that the user can click on a name and open the file.
[Code]....
But of course the Name field in the hyperlink column is only the name of the file - how do I append the relative link to the filename to make the full path to the file correct.I tried to make the Hyperlink column a template field and do something like EVAL("~/path/"&"Name") but that doesn't work :(
I want to transfer data from datatable to a gridview with a hyperlink column. But dont know how to do.
I attach my code as below, what i want to do is to output 2 columns in gridview, and the first column should be a hyperlink. However, now the first column still shows nothing.