Web Forms :: Hyperlink Column In Grid Is Not Formatting Properly?
Apr 12, 2010
In gridview I am adding row as mentioned below
string hyPerLinkUri = DispForm.aspx?ID=" + result["ID"].ToString()
row["Schedule ID"] = hyPerLinkUri;
Then I added hyperlinkfield column grid
[Code]....
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.
View 2 Replies
Similar Messages:
Nov 8, 2010
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.
View 3 Replies
Nov 18, 2010
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
View 3 Replies
Oct 26, 2010
I have been using gridview with my sql server data-
[Code]....
Now here my ann_vol is displayed upto 8 decimal places.But i want to format it like 24.00 upto 2 decimal placesHow can i achieve this
View 3 Replies
Mar 26, 2010
I have a gridview, and i have set all the properties to this...it all works.
I then created a AutoGenerateEditButton.....but I need to know how to set the below for the Edit button.
<HeaderStyle BackColor="White" BorderColor="#6778B2" BorderStyle="Solid"
BorderWidth="1px" Font-Bold="True" Font-Names="Tahoma,Arial,sans-serif;"
Font-Size="99%" Width="0px" />
<ItemStyle BorderColor="#6778B2" BorderStyle="Solid" BorderWidth="1px"
Font-Names="Tahoma,Arial,sans-serif;" Font-Size="99%" HorizontalAlign="Left" />
View 2 Replies
Feb 2, 2011
I have an entity "Order", which contains a set of states. Every state has date and name.
I want show grid with all orders and in grid one column with last state of order. But I dont understand how to do it.
View 1 Replies
Jun 21, 2010
I have a Gridview and I want to format 2nd column of it to {0:dd-MMM-yy}
If it is not autogeneratedcolumn Gridview I would have used DataFormatString="{0:dd-MMM-yy}"
However, this time it is a autogeneratedcolumn Gridview so I cannot use the above code anymore.
So can I set that column format programmatically ?
I tried
GridView1.Columns(1).
But then there is nothing close to dataformat pops up from intellisense.
View 7 Replies
Mar 29, 2010
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?
View 2 Replies
Mar 30, 2010
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
View 2 Replies
Nov 9, 2010
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
<object id='video' width='462' height='407' type='application/x-shockwave-flash'
data='http://view.vzaar.com/286291.flashplayer'>
<param name='movie' value='http://view.vzaar.com/286291.flashplayer'>
<param name='allowScriptAccess' value='always'>
<param name='allowFullScreen' value='true'>
<param name='wmode' value='transparent'>
<param name='flashvars' value='colourSet=blue&brandText=LSAT+Freedom&brandLink=lsatfreedom.com'>
<embed src='http://view.vzaar.com/286291.flashplayer'></embed>
</object>
When I comment to this column while binding, my grid is working fine and showing all next records.
But I want this column.
How to bind <object ....> tag to grid so that a video can be displayed.
View 1 Replies
May 27, 2010
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
View 5 Replies
Jun 3, 2010
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.
[Code]....
View 8 Replies
Jun 2, 2010
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..
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
gv_photo.EditIndex = e.NewEditIndex;
bindgrid("album_id");
public void bindgrid(string sort)
string str = "select * from tbl_Album";
[code]...
View 2 Replies
Feb 25, 2011
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);
}
}
}
View 4 Replies
Apr 9, 2010
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.
View 5 Replies
Mar 22, 2010
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
View 1 Replies
Oct 19, 2010
I'm trying to retreive a column value from gridview5 to use it in a query to display resuls in gridview, Also how do you hide a column in the grid?
Where (p.Link_ID Like GridView5.?
[code]....
View 3 Replies
Nov 23, 2010
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
View 4 Replies
Mar 11, 2011
How do I do this for my gridview?
I tried this but gettiing variable 'h1' is used before it has been assigned a value. What am I doing wrong?
[Code]....
View 12 Replies
Jan 15, 2010
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.
View 11 Replies
Mar 8, 2010
[code]....
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?
View 16 Replies
Aug 27, 2010
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 :(
[Code]....
View 3 Replies
Sep 5, 2010
how can i convert column in grid view into hyperlink
View 6 Replies
Jan 4, 2011
i have a gridview of a list of VehicleRequisition's with a column whose itemtemplate is as follows.
[Code]....
[Code]....
View 2 Replies
Feb 10, 2011
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.
Web page code:
[Code]....
C# code:
[Code]....
View 6 Replies