<asp:BoundField DataField="ComputerModel" HeaderText="ComputerModel"
SortExpression="ComputerModel"
ItemStyle-Width="50px"/>
<asp:CheckBoxField DataField="Lease" HeaderText="Lease"
SortExpression="Lease" />
<asp:BoundField DataField="SerialNumber" HeaderText="SerialNumber"
SortExpression="SerialNumber" />
<asp:BoundField DataField="LeasedTagNum" HeaderText="LeasedTagNum"
SortExpression="LeasedTagNum" />
<asp:BoundField DataField="MonitorType" HeaderText="MonitorType"
SortExpression="MonitorType" />
<asp:BoundField DataField="MonitorCount" HeaderText="MonitorCount"
SortExpression="MonitorCount" />
<asp:CommandField ShowEditButton="True" ShowInsertButton="True" />
</Fields>
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
Try something like this:
<asp:BoundField DataField="ComputerModel" ItemStyle-Width="50px"/>
where 50px is the width you need.
Try this:
<asp:BoundField DataField="ComputerModel" HeaderText="ComputerModel"
SortExpression="ComputerModel"
HeaderStyle-Width="50px" >
</asp:BoundField>
Can we see all the HTML for the control? I'm curious to see the markup for the entire control so I don't make any assumptions.
Per MSDN try
<asp:boundfield
sortexpression="LastName"
datafield="LastName"
headertext="LastName">
<itemstyle width="50px">
</itemstyle>
</asp:boundfield>
I would like to see what you have thus far and maybe I can be more helpful. Also is there any CSS class that may be setting the item width?
Related
I have the bottom Details view and it shows one detail on a single row is there any there any method that i could use do that i can show multiple detail view objects
<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px"
AutoGenerateRows="False" EnableViewState="False"
DataKeyNames="questionID" DataSourceID="AllQuestions" AllowPaging="True">
<Fields>
<asp:BoundField DataField="SubjectName" HeaderText="SubjectName"
SortExpression="SubjectName" />
<asp:BoundField DataField="Chapter" HeaderText="Chapter"
SortExpression="Chapter" />
<asp:BoundField DataField="Section" HeaderText="Section"
SortExpression="Section" />
<asp:BoundField DataField="questionID" HeaderText="questionID"
InsertVisible="False" ReadOnly="True" SortExpression="questionID" />
<asp:BoundField DataField="name" HeaderText="name" SortExpression="name" />
<asp:BoundField DataField="sectionID" HeaderText="sectionID"
SortExpression="sectionID" />
<asp:BoundField DataField="QuestionNo" HeaderText="QuestionNo"
SortExpression="QuestionNo" />
<asp:BoundField DataField="question" HeaderText="question"
SortExpression="question" />
<asp:BoundField DataField="A" HeaderText="A" SortExpression="A" />
<asp:BoundField DataField="B" HeaderText="B" SortExpression="B" />
<asp:BoundField DataField="C" HeaderText="C" SortExpression="C" />
<asp:BoundField DataField="D" HeaderText="D" SortExpression="D" />
<asp:BoundField DataField="correctAnswer" HeaderText="correctAnswer"
SortExpression="correctAnswer" />
<asp:BoundField DataField="explanation" HeaderText="explanation"
SortExpression="explanation" />
</Fields>
</asp:DetailsView>
Not that I know of.... DetailsView is meant for a single record. Use a GridView or Repeater or ListView for multiple records.
I have a gridview on my webpage with one of the columns as a "Reference Number". The reference number represents the name of a pdf file on the server. Is it possible change this column to a hyperlink column so that when they click on the Reference Number on the row it opens the pdf? For example they click on ReferenceNumber 123456 and it opens up the pdf \server\folder\123456.pdf. Thank you
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
CellPadding="4" DataSourceID="SqlDataSource1"
ForeColor="#333333" GridLines="None">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="ReferenceNumber" HeaderText="Reference #"
SortExpression="ReferenceNumber" />
<asp:BoundField DataField="Teaching_Hospital_Name" HeaderText="Teaching Hospital Name"
SortExpression="Teaching_Hospital_Name" />
<asp:BoundField DataField="Date_of_Payment"
HeaderText="Date" SortExpression="Date_of_Payment" />
<asp:BoundField DataField="Physician_First_Name"
HeaderText="First Name" SortExpression="Physician_First_Name" />
<asp:BoundField DataField="Physician_Last_Name"
HeaderText="Last Name" SortExpression="Physician_Last_Name" />
<asp:BoundField DataField="Recipient_Primary_Business_Street_Address_Line_1"
HeaderText="Address 1"
SortExpression="Recipient_Primary_Business_Street_Address_Line_1" />
<asp:BoundField DataField="Recipient_City" HeaderText="City"
SortExpression="Recipient_City" />
<asp:BoundField DataField="Recipient_State" HeaderText="State"
SortExpression="Recipient_State" />
<asp:BoundField DataField="Recipient_Zip_Code" HeaderText="Zip"
SortExpression="Recipient_Zip_Code" />
<asp:BoundField DataField="Total_Amount_of_Payment" HeaderText="Total_Amount"
SortExpression="Total_Amount_of_Payment" />
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
You need to change the Reference Number field to a TemplateField instead of a BoundField, this will allow you to put a hyperlink into that field.
Read Using TemplateFields in the GridView Control
From there, I would suggest using an HttpHandler to build the PDF file and stream it to the user. This has two benefits:
There is no postback, so the user does not lose their place in your grid display.
It allows the user to easily view and/or save the PDF separate from you application.
I am working on an asp.net page. In which I am using a grid view. I want to be able to change the width of the bound fields. I am using
ControlStyle-Width="100px" and itemstyle-width but I unable to change width of bound field. Can anyone tell me how this could be done?
<asp:BoundField DataField="ptDob" HeaderText="PatientDob" HeaderStyle-HorizontalAlign="Left" SortExpression="ptDob" ControlStyle-Width="2500px" />
<asp:BoundField DataField="memid" HeaderText="MemberId" HeaderStyle-HorizontalAlign="Left" ControlStyle-Width="100px"
SortExpression="memid" />
<asp:BoundField DataField="memssn" HeaderText="MembeSsn" HeaderStyle-HorizontalAlign="Left" ItemStyle-Width="100px"
SortExpression="memssn" />
<asp:BoundField DataField="billType" HeaderText="BillType" HeaderStyle-HorizontalAlign="Left" ItemStyle-Width="100px"
SortExpression="billType" />
<asp:BoundField DataField="insuranceName" HeaderText="insuranceName" HeaderStyle-HorizontalAlign="Left" ItemStyle-Width="100px"
SortExpression="insuranceName" />
<asp:BoundField DataField="taxId" HeaderText="TaxId" HeaderStyle-HorizontalAlign="Left" ItemStyle-Width="100px"
SortExpression="taxId" />
<asp:BoundField DataField="attendingProvider" HeaderText="AttendingProvider" HeaderStyle-HorizontalAlign="Left" ItemStyle-Width="100px"
SortExpression="attendingProvider" />
<asp:BoundField DataField="parStatus" HeaderText="parStatus" HeaderStyle-HorizontalAlign="Left" ItemStyle-Width="100px"
SortExpression="parStatus" />
<asp:BoundField DataField="admittedDate" HeaderText="AdmittedDate" HeaderStyle-HorizontalAlign="Left"
SortExpression="admittedDate" />
<asp:BoundField DataField="billedAmount" HeaderText="BilledAmount" HeaderStyle-HorizontalAlign="Left"
ItemStyle-Width="100px" or HeaderStyle-Width="100px" should perfectly work, maybe you have some other style interfering, CSS maybe.
You can add it as a CSS field in your itemstyle. Then make sure the class has a width set. Assuming you've not got any inline styles that take precedence then this will work.
<asp:BoundField DataField="parStatus" HeaderText="parStatus">
<ItemStyle CssClass="yourclass"></ItemStyle>
</asp:BoundField>
Try Using HeaderText-cssClass, in class add
padding-left: 100px;
padding-right: 100px;
i use this code .. but when the hyperlinks are longer then field size the gridview expands verticaly. i want the link below as like a paragraph . give me a solution
<asp:gridview id="titlesGrid" runat="server"
datasourceid="titles"
width=90% cellpadding=5 font-size="8pt"
autogeneratecolumns=false
headerstyle-backcolor="maroon"
headerstyle-forecolor="khaki"
headerstyle-font-bold
rowstyle-verticalalign="top">
<columns>
<asp:hyperlinkfield headertext="Title"
datatextfield="title"
datanavigateurlformatstring="title_details.aspx?titleid={0}"
datanavigateurlfields="title_id" />
<asp:boundfield headertext="Title ID"
datafield="title_id" />
<asp:boundfield headertext="Category"
datafield="type" />
<asp:boundfield headertext="Pub ID"
datafield="pub_id" />
<asp:boundfield headertext="Price"
datafield="price"
htmlencode=false
dataformatstring="{0:n2}"
itemstyle-horizontalalign="right" />
</columns>
</asp:gridview>
Have you tried using <ItemStyle Wrap="True" /> for <asp:hyperlinkfield /> ?
How do you control the column width in a gridview control in ASP.NET 2.0?
You can use the HeaderStyle-Width, ItemStyle-Width or FooterStyle-Width properties. These can be applied to all the columns or per-column basis.
<asp:GridView ID="GridView1" runat="server">
<HeaderStyle Width="10%" />
<RowStyle Width="10%" />
<FooterStyle Width="10%" />
<Columns>
<asp:BoundField HeaderText="Name" DataField="LastName"
HeaderStyle-Width="10%" ItemStyle-Width="10%"
FooterStyle-Width="10%" />
</Columns>
</asp:GridView>
I do it using the header style for the column:
<asp:BoundField HeaderText="Name" DataField="LastName">
<HeaderStyle Width="20em" />
</asp:BoundField>
Here's the C# code to do it programatically:
columnName.ItemStyle.Width = Unit.Percentage(someDouble);
Gridview.Columns[1].ItemStyle.Width = 100;
This will set the with in pixel.