PDA

View Full Version : سوال: تغییر اندازه بعضی از ستون های گریدویو



veniz2008
دوشنبه 01 خرداد 1391, 22:17 عصر
سلام دوستان،تو سایت جستجو کردم ولی مشکلم حل نشد،سوالم اینه: میخوام طول بعضی از ستون های گرید رو بیشتر کنم ولی هر کاری کردم تغییری ایجاد نشد(بازم تاکید میکنم فقط طول بعضی از ستون ها رو میخوام تغییر بدم)،لطفا یه توضیح کامل بدید چون خودم هرچی با خصوصیاتش ور رفتم به جایی نرسیدم،تشکر.

hamid_shrk
دوشنبه 01 خرداد 1391, 23:19 عصر
سلام
شما باید تگ Item style رو مقدار بدید :


<asp:BoundField DataField="PCCount" HeaderText="کاربر" SortExpression="PCCount">
<ItemStyle HorizontalAlign="Center" Width="30px" />
</asp:BoundField>
<asp:BoundField DataField="duration" HeaderText="سال" SortExpression="duration">
<ItemStyle HorizontalAlign="Center" Width="30px" />
</asp:BoundField>

mhaghp
سه شنبه 02 خرداد 1391, 11:20 صبح
سلام
شما باید تگ Item style رو مقدار بدید :


<asp:BoundField DataField="PCCount" HeaderText="کاربر" SortExpression="PCCount">
<ItemStyle HorizontalAlign="Center" Width="30px" />
</asp:BoundField>
<asp:BoundField DataField="duration" HeaderText="سال" SortExpression="duration">
<ItemStyle HorizontalAlign="Center" Width="30px" />
</asp:BoundField>


ولی من این کار انجام دادم بازهم نشد

naser_feb8646
سه شنبه 02 خرداد 1391, 11:43 صبح
سلام
میشه لطف کنید و کدتون رو بزارید تا بهتر بشه کمکتون کرد

mhaghp
سه شنبه 02 خرداد 1391, 15:05 عصر
سلام
میشه لطف کنید و کدتون رو بزارید تا بهتر بشه کمکتون کرد
این تصویری از اجرای برنامه می باشد که همینطور که می بینید گزارش یا گرید از صفحه زده بیرون من می خواهم گزارش در صفحه جا شود یا اندازه صفحه مثل گرید ویو شود
و کدهای برنامه
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Report_History_Level3.aspx.cs" Inherits="Report_Sum_Budget" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">
.style1
{
width: 21%;
}
.style2
{
width: 44px;
}
.style3
{
width: 44px;
height: 31px;
}
.style4
{
height: 31px;
}
.style5
{
width: 44px;
height: 19px;
}
.style6
{
height: 19px;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<br />

<table class="style1">
<tr>
<td class="style2" width="20px">
<asp:Label ID="Label1" runat="server" Text="سال:" style="text-align: left"
Width="100px"></asp:Label></td>
<td>
<asp:DropDownList ID="ddlYear" runat="server" Height="20px" Width="82px">
<asp:ListItem>90</asp:ListItem>
<asp:ListItem>91</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style3" width="20px">
<asp:Label ID="Label2" runat="server" Text="از ماه:" style="text-align: left"
Width="100px"></asp:Label></td>
<td class="style4">
<asp:DropDownList ID="ddlFromMonth" runat="server" Height="20px" Width="82px">
<asp:ListItem Value="90-01">فروردین</asp:ListItem>
<asp:ListItem Value="90-02">اردیبهشت</asp:ListItem>
<asp:ListItem Value="90-03">خرداد</asp:ListItem>
<asp:ListItem Value="90-04">تیر</asp:ListItem>
<asp:ListItem Value="90-05">مرداد</asp:ListItem>
<asp:ListItem Value="90-06">شهریور</asp:ListItem>
<asp:ListItem Value="90-07">مهر</asp:ListItem>
<asp:ListItem Value="90-08">آبان</asp:ListItem>
<asp:ListItem Value="90-09">آذر</asp:ListItem>
<asp:ListItem Value="90-10">دی</asp:ListItem>
<asp:ListItem Value="90-11">بهمن</asp:ListItem>
<asp:ListItem Value="90-12">اسفند</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style5" width="20px">
<asp:Label ID="Label3" runat="server" Text="تا ماه:" style="text-align: left"
Width="100px"></asp:Label></td>
<td class="style6">
<asp:DropDownList ID="ddlToMonth" runat="server" Height="20px" Width="82px">
<asp:ListItem Value="90-01">فروردین</asp:ListItem>
<asp:ListItem Value="90-02">اردیبهشت</asp:ListItem>
<asp:ListItem Value="90-03">خرداد</asp:ListItem>
<asp:ListItem Value="90-04">تیر</asp:ListItem>
<asp:ListItem Value="90-05">مرداد</asp:ListItem>
<asp:ListItem Value="90-06">شهریور</asp:ListItem>
<asp:ListItem Value="90-07">مهر</asp:ListItem>
<asp:ListItem Value="90-08">آبان</asp:ListItem>
<asp:ListItem Value="90-09">آذر</asp:ListItem>
<asp:ListItem Value="90-10">دی</asp:ListItem>
<asp:ListItem Value="90-11">بهمن</asp:ListItem>
<asp:ListItem Value="90-12">اسفند</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style2">
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="اعمال فیلتر" style="text-align: center" Width="100px" />
</td>
<td>
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="اکسل"
Width="100px" style="text-align: center" />
</td>
</tr>
<tr>
<td colspan="2">

</td>
</tr>
</table>
<br />
<table width="500px">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
ShowFooter="True"
PageSize="15" CellPadding="4" ForeColor="#333333" GridLines="None"
AllowPaging="True" onrowdatabound="GridView1_RowDataBound"
onpageindexchanging="GridView1_PageIndexChanging"
onselectedindexchanged="GridView1_SelectedIndexChanged" >
<Columns>
<asp:BoundField HeaderStyle-Width="5px" DataField="ProjectNo"
HeaderText="کد پروژه فرعی" >


<HeaderStyle Width="5px" Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False"></HeaderStyle>
<ItemStyle Font-Names="B Nazanin" HorizontalAlign="Center" Width="5px" />
</asp:BoundField>


<asp:BoundField ItemStyle-Width="5px" HeaderStyle-Width="5px"
DataField="W01" HeaderText="کارکرد ماه فروردین" >
<HeaderStyle Width="5px" Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False"></HeaderStyle>

<ItemStyle Width="5px" Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="W02" HeaderText="کارکرد ماه اردیبهشت"
>
<HeaderStyle Font-Names="B Nazanin" HorizontalAlign="Center" Width="5px"
Wrap="False" />
<ItemStyle HorizontalAlign="Center" Width="5px" Font-Names="B Nazanin" Wrap="False"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="W03" HeaderText="کارکرد ماه خرداد"
>
<HeaderStyle Font-Names="B Nazanin" Wrap="False" />
<ItemStyle HorizontalAlign="Center" Width="5px" Font-Names="B Nazanin" Wrap="False"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="W04" HeaderText="کارکرد ماه تیر" >
<HeaderStyle Font-Names="B Nazanin" Wrap="False" />
<ItemStyle Font-Names="B Nazanin" HorizontalAlign="Center" Width="5px"
Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="W05" HeaderText="کارکرد ماه مرداد" >


<HeaderStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />
<ItemStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />
</asp:BoundField>


<asp:BoundField DataField="W06" HeaderText="کارکرد ماه شهریور" >
<HeaderStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />
<ItemStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="W07" HeaderText="کارکرد ماه مهر" >
<HeaderStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />
<ItemStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="W08" HeaderText="کارکرد ماه آبان" >
<HeaderStyle Font-Names="B Nazanin" Wrap="False" />
<ItemStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="W09" HeaderText="کارکرد ماه آذر" >
<HeaderStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />
<ItemStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="W10" HeaderText="کارکرد ماه دی" >
<HeaderStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />
<ItemStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="W11" HeaderText="کارکرد ماه بهمن" >
<HeaderStyle Font-Names="B Nazanin" Wrap="False" />
<ItemStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="W12" HeaderText="کارکرد ماه اسفند" >
<HeaderStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />
<ItemStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="ProjectTitle" HeaderText="عنوان پروژه فرعی" >


<HeaderStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />


<ItemStyle HorizontalAlign="Center" Height="1px" Width="50px" Wrap="False" Font-Names="B Nazanin"></ItemStyle>



</asp:BoundField>
<asp:BoundField DataField="Year" HeaderText="سال" >
<HeaderStyle Font-Names="B Nazanin" />
<ItemStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="BudgetNo" HeaderText="ردیف بودجه" >
<HeaderStyle HorizontalAlign="Center" Wrap="False" />
<ItemStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />
</asp:BoundField>
<asp:BoundField ItemStyle-Width="0px" ItemStyle-Font-Size="Smaller"
DataField="BudgetTitle" HeaderText="عنوان توافقنامه" >


<HeaderStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />


<ItemStyle Width="5px" Wrap="False" Font-Names="B Nazanin" HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>


<asp:BoundField DataField="PersonId" HeaderText="شماره پرسنلی" >
<HeaderStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />
<ItemStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="FullName" HeaderText="نام و نام خانوادگی" >


<HeaderStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />
<ItemStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />
</asp:BoundField>


<asp:BoundField DataField="Work" HeaderText="جمع کارکرد" >
<HeaderStyle HorizontalAlign="Center" Wrap="False" />
<ItemStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="SazmaniCost" HeaderText="دستمزد سازمانی" >
<HeaderStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />
<ItemStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="KhadamatCost"
HeaderText="دستمزد خدمات اداری شهر" >
<HeaderStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />
<ItemStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="SaatiCost" HeaderText="دستمزد ساعتی" >
<HeaderStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />
<ItemStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="BehramanKarCost" HeaderText="دستمزد بهرمان کار" >
<HeaderStyle Font-Names="B Nazanin" HorizontalAlign="Center" Wrap="False" />
<ItemStyle Font-Names="B Nazanin" HorizontalAlign="Center" Width="5px"
Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="TotalPersonCost" HeaderText="کل دستمزد" >
<HeaderStyle Font-Names="B Nazanin" HorizontalAlign="Center" Width="5px"
Wrap="False" />
<ItemStyle Font-Names="B Nazanin" HorizontalAlign="Center" Width="5px"
Wrap="False" />
</asp:BoundField>
</Columns>
<PagerSettings FirstPageText="اول" LastPageText="آخر" />
<RowStyle BackColor="#EFF3FB" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
</table>
</asp:Content>

TeacherMath
سه شنبه 02 خرداد 1391, 17:16 عصر
به اون ستون ها یه cssClss اضافه کنید
<asp:BoundField DataField="Last Name" HeaderText="Last Name"
SortExpression="Last Name" >
<ControlStyle CssClass="ColBig" />

</asp:BoundField>
بعد توی اون کلاس اندازه را زیاد کن.
مثلا:

.ColBig
{
width: 25px;
}

veniz2008
سه شنبه 02 خرداد 1391, 20:01 عصر
یه راه ساده تر پیدا کردم البته همون itemstyle هست فقط ویزاردی کار میکنی و کدنویسی نداری!،خوب گزینه edit columns از گرید رو بزنید، از بین ستون های گریدتون اون ستونی که میخواید طولش(پهناش) رو تغییر بدید انتخاب و سپس از پنجره سمت راست و درقسمت Styles گزینه ItemStyle رو انتخاب و علامت + کنار اونو بزنید سپس در خصوصیت width مقدار دلخواه خودتون رو تایپ و تایید کنید( مثلا 250px )،مشاهده خواهید کرد که طول ستون مورد نظر تغییر میکنه،موفق باشید.