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 am trying to populate an (editable) gridview in ASP.NET with a table from SQL. I have a SQLDataSource set up for this. I also need to have this gridview be filterable based on parameters entered in textboxes. I have tried using ControlParameters for this and it works but the problem there is when all textboxes are empty I want it to display all results in the gridview. What it does is display nothing because no entries have parameters that equal "". Is there an easy way to do this that I am missing or is there a better way to go about it other than a SQLDataSource?
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); } } }
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.
my problem is that i have a gridview that fetch the data from database .I added the linkbutton on gridview that redirect to next page but cant working becouse at run time i add a bound field on gridview to calculate the time. source code
I have an application that uses an aps:GridView. The GridView is populated using a DataSource that calls a Stored Procedure. The DataSource passes parameters to the Stored Procedure based on some text fields. The page has been running slower than wanted, so I was doing some checking.
I ran SQL Profiler while loading the page, and saw the Stored Procedure was being called twice. I stepped through the code and found out that in the Page Load Complete event was where this was happening. In this event, I set the value of a parameter for the Stored Procedure, then did a DataBind on the GridView to pick up the data. As I was stepping through the code, I watched the SQL Profiler. When I got to the step of setting the parameter, the Stored Procedure had not yet been called. When I stepped through that and got to the DataBind command (before running that step), the SQL Profiler showed that the Stored Procedure had been called. Then I did the DataBind and the StoredProcedure was called again.
My question is, how do I get the parameters set, and get the GridView data bound, and only call the StoredProcedure once? If I comment out the DataBind step, the StoredProcedure never does get called (which seems really strange to me...).
I have a gridview control bound to a sqldatasource in c#. In the rowdatabound event I look at a value in a cell and use a function to evaluate the value and depending on that value I populate an added unbound column in my bound datagrid to show an excalmation point. I now want to sort by the column with the excalmation point.
Problem in YUI:I am using YUI grid,my dataset contains some special character.i bind my dataset into the grid,but its not displayed in my grid? how to solve this
Have a GridView with a templated select button hidden and using
e.Row.Attributes.Add("onclick",Page.ClientScript.GetPostBackEventReference(this.grdMaster, "Select$" + e.Row.RowIndex.ToString())); to select a row .
When user like to update the datasource he will select one row from gridview then in selected indexchanged event i would display the selected row values beneath the form under the grid , Then user will update the contents displayed from grid and click an update button which is outside the grid . After updating the displayed row , i got to get the values of the next row in the grid and display them for next updation , i'e if users maually selects row 3 from grid then he can update the values using the update button and then on update click itself i'll have to display next row contents of row 4 and this process could go on .
I have Parent/Child Grid (also called Nested Grids).
Parent Grid (PG) :: PG has two template fields. 1st template field has "Category ID" and 2nd template has Child Grid
Child Grid (CG) :: CG is populated in PG's RowDataBund event based on "Category ID". In CG's DataBound event, I am doing something which I need to display in CG's footer row.
Problem :: In the footer row of each CG, I have to show the "Category ID" which is in PG' row. How can I get hold of the PG's row which hascurrent nested grid (there will 'n' child grids, one for each 'Category ID' in the PG ) so I can read the "Category ID"
I was thinking if I could do something (DataBound event of CG) like this..
string catId = ChildGrid.Parent[get the index of the current row in PG].Cells[0].Text;
In a ASP.NET application I have a paging RadGrid which shows up textbox in each row. Outside the grid, there is an OK button to save the content of all the textbox. If user changes text in any one or more of the textbox and without clicking on the "OK" button, tries to move to a different page number (of the grid by clicking on the page number), he should be prompted for confirmation of save or cancel the changes.
I am guessing that one can write a Javascript function which would look for any form input control (textbox in my case) and detect changes and If there are changes, would prompt the user. However, I am not sure where I can call this function from?
I am using RadGrid but I guess this should be applicable to GridView as well.
and here is my code that parses the xml and tries to bind the grid. What am I missing here?
var retVal = service.GetTripDetailsByTripID(tripId); var xmlTrips = XDocument.Parse(retVal); var tripTolls = from t in xmlTrips.Elements("TripTollCompleteDC") select new { TripTollId = (int)t.Element("TripTollId") , DMSLaneModeID = (int?)t.Element("DMSLaneModeID") , HOVOnly = (bool)t.Element("HOVOnly") , CreateDateTime = (DateTime)t.Element("CreateDateTime") , ConfigVTMSDelaySeconds = (int)t.Element("ConfigVTMSDelaySeconds") }; grdTripDetails.DataSource = tripTolls; grdTripDetails.DataBind();
I realize these are anonymous types. Is that a problem? I have verified the service is returning the Xml as stated above. Can anyone out there point me in the right direction? Just for completeness, here is the grid markup <asp:GridView runat="server" ID="grdTripDetails" />
I am trying to create a second grid in the same page with detailed info for a given record of the first Grid, but when I press select in the first grid nothing happens. I follwed everything I read.
I have a grid view that does add, edit update and delete. ( I draged the grid to the aspx page ) it is working. I would like to have the following : once I lick on edit, I open a form inside the grid view to edit the fields. How can I do that.
I'm using ASP.NET/VB and am wanting to nest a grid inside of another grid. I've seen them but am unsure how to make them work. I have a Orders table with an OrderID and it is linked to a Orders_Detail table. I would like to be able to select the order and see the details. I've done it differently with 2 grids outside of each other, but this isn't the solution I need.
I have a Select All checkbox in my grid that calls this function...works fine. Outside of my grid I'd like to use another checkbox for something else, but when the select all checkbox in the grid is selected, it also selects my checkbox outside of the grid. Is there way to make the checkbox outside of the grid independent from the ones in the grid?
i have a gridview in which there is another gridview now i want the data in the primary as well as the nested gridview in pdf and excel format. i have tried all sort of things how ever none is working can anyone send me the working code for pdf and excel for grid with in a grid.
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