Gridview - محاذاة مركز الوسم 'EmptyDataText' & حتى انها ليست الافتراضي يسار الصفحة

StackOverflow https://stackoverflow.com/questions/1612210

سؤال

لدي gridview التحكم في c# البرنامج.في الأساس شخص يدخل عنوان البريد الإلكتروني والبيانات ثم هو مبين في gridview ولكن إذا كان لا يمكن العثور على عنوان البريد الإلكتروني, يتم عرض رسالة باستخدام EmptyDataText="لا توجد بيانات" الوسم ولكن لا يبدو أن نمط النص 'لا توجد بيانات متاحة' حيث يظهر في وسط الصفحة بدلا من الافتراضي اليسار.على الرغم من CSS لا يبدو أن العمل كما يمكن تغيير حجم الخط و نوع ولكن ليس text-align:center.

لقد حاولت عدد من الخيارات المختلفة:

<EmptyDataRowStyle Font-Size="12px" text-align="center" />

المشكلة text-align:center ليست سمة صالح.

وثمة خيار آخر هو:

<EmptyDataRowStyle cssclass="mycentertext" />

ثم رابط أسلوبي.ملف css في ذلك:

.mycentertext {text-align: center;font-size: 12px;font-family: Verdana;}

مرة أخرى, الخط تغيير حجم و نوع الخط ولكن لا يزال الانحياز.

الرجاء المساعدة!

هذا هو بلدي gridview:

<asp:GridView ID="GridView1" Visible="false" runat="server" AutoGenerateColumns="False" DataKeyNames="ID"
                DataSourceID="SqlDataSource" EmptyDataText="No data could be found for the email address" CellSpacing="3" CellPadding="4"
                GridLines="None" ForeColor="#333333">
                <Columns>
                    <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
                        SortExpression="ID">
                        <ItemStyle Font-Names="Verdana" Font-Size="9pt" />
                        <HeaderStyle Font-Names="Verdana" Font-Size="10pt" />
                    </asp:BoundField>
                    <asp:BoundField DataField="name" HeaderText="Name" SortExpression="name">
                        <ItemStyle Font-Names="Verdana" Font-Size="9pt" />
                        <HeaderStyle Font-Names="Verdana" Font-Size="10pt" />
                    </asp:BoundField>
                    <asp:BoundField DataField="EmailAddress" HeaderText="Email Address" SortExpression="EmailAddress">
                        <ItemStyle Font-Names="Verdana" Font-Size="9pt" />
                        <HeaderStyle Font-Names="Verdana" Font-Size="10pt" />
                    </asp:BoundField>
                    <asp:BoundField DataField="Address1" HeaderText="Address1" SortExpression="Address1">
                        <ItemStyle Font-Names="Verdana" Font-Size="9pt" />
                        <HeaderStyle Font-Names="Verdana" Font-Size="10pt" />
                    </asp:BoundField>
                    <asp:BoundField DataField="Address2" HeaderText="Address2" SortExpression="Address2">
                        <ItemStyle Font-Names="Verdana" Font-Size="9pt" />
                        <HeaderStyle Font-Names="Verdana" Font-Size="10pt" />
                    </asp:BoundField>
                    <asp:BoundField DataField="city" HeaderText="City" SortExpression="city">
                        <ItemStyle Font-Names="Verdana" Font-Size="9pt" />
                        <HeaderStyle Font-Names="Verdana" Font-Size="10pt" />
                    </asp:BoundField>
                </Columns>

                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                <FooterStyle BackColor="#5D7B9D" ForeColor="White" Font-Bold="True" />
                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                <EditRowStyle BackColor="#999999" />
                <EmptyDataRowStyle cssclass="mycentertext" />
            </asp:GridView>
هل كانت مفيدة؟

المحلول

ماذا يحدث إذا قمت بإضافة HorizontalAlign="Center" إلى EmptyDataRowStyle علامة ؟ أيضا, هل تستخدم جلود ؟

نصائح أخرى

جهاز محدد في كود css يجب أن تكون:

tr.mycentertext td { text-align:center;font-size:12بكسل;font-family:Verdana;}

كل ما عليك القيام به هو إضافة إلى gridview a CssClass="myGrid و في ذلك "myGrid" style يجب إضافة margin: 0 auto و التي سوف محاذاة emptydata رسالة إلى المركز.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top