Blog Of Sem: ASPXGRIDVIEW İşlemleri

ASPXGRIDVIEW İşlemleri

Gridviewde seçili satırın bilgisini alabilme :
        protected void ASPxGridView1_SelectionChanged(object sender, EventArgs e)
        {
            var products = ASPxGridView1.GetSelectedFieldValues("NAME");
            Label1.Text = products[0].ToString();
        }



Gridviewin Sonuna İşlemler Seç eklemek için source da sona ekle
            <dx:GridViewDataHyperLinkColumn Caption="İşlemler" FieldName="ID">
                <PropertiesHyperLinkEdit NavigateUrlFormatString="page.aspx?id={0}" Text="SEÇ" />
            </dx:GridViewDataHyperLinkColumn>


        </Columns>
    </dx:ASPxGridView>



Gridview devexpress 7.2 sonrası için gecerli export Gridview
<Columns>un altina ekle
 <SettingsExport EnableClientSideExportAPI="true" ExcelExportMode="WYSIWYG" />

<Columns>un ustune ekle
        <Toolbars>
            <dx:GridViewToolbar EnableAdaptivity="true">
                <Items>
                    <dx:GridViewToolbarItem Command="ExportToPdf" />
                    <dx:GridViewToolbarItem Command="ExportToXls" />
                    <dx:GridViewToolbarItem Command="ExportToXlsx" />
                    <dx:GridViewToolbarItem Command="ExportToDocx" />
                    <dx:GridViewToolbarItem Command="ExportToRtf" />
                    <dx:GridViewToolbarItem Command="ExportToCsv" />
                </Items>
            </dx:GridViewToolbar>
        </Toolbars>


Gridview grup category combobox ve baglantisi 
birinci sqldatasource_musteriler yarat ve bunu aspxgridviewe bind
Ikinci datasource sqldatasource_musterigruplari  yarat  bu bir yere bind olmayacak

Sqlden iki tablo yarat birinin adi musteri(id,adi,grupid) olsun
digeride musteri_grup (id,grup_adi) olsun

aspxgridview designerda columnsa tikla combobox column ekle captionunu grup yap, Fieldname grupid sec, sag tabda comboboxpropertiesde datasourceid musteri_gruplarini sec text field grup_adi , valuefield=id 


Gridview Horizontal scrollbar 

    <dx:ASPxGridView Width="100%" ID="ASPxGridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" KeyFieldName="ID" OnCellEditorInitialize="ASPxGridView1_CellEditorInitialize">

        <Settings ShowFilterRow="True" ShowGroupPanel="True" />

        <Settings HorizontalScrollBarMode="Auto" />

        <Settings VerticalScrollBarMode="Auto" />

Datasource eklemede hata alırsan sol taraftan server explorerden modify deyip save passwordu seç






Gridview  Required zorunlu alan ayari
Designerda ac ve columnsdan zorunlu alana tıkla ve sağda textboxpropertiesden en aşağıda validation settingste requiredi true yap





Master Detail Grid
ONCE 2 TANE SQLDATASOURCE VE 2 TANE ASPXGRIDVIEW YARAT BIRI MUSTERILER DIGERI MUSTERI HAREKETLER
MUSTERILERI NORMAL TABLODAN AL ASPXGRIDVIEW MUSTERILERIN SETTINGS DETAILDE DETAILROWU TRUE YAP,

MUSTERI HAREKETLERINIDE AL WHERE KISMINA TIKLA COLUMN MUSTERI_ID OPERATOR " = "  , SOURCE SESSION , SESSION FIELD = MUSTERI_ID

VE DAHA SONRA KODA EKLE
        protected void ASPxGridViewmusterihareketler_BeforePerformDataSelect(object sender, EventArgs e)
        {
            Session["MUSTERI_ID"] = (sender as ASPxGridView).GetMasterRowKeyValue();
        }


SON OLARAKDA ASPXGRIDVIEWMUSTERILERE TIKLA EDITTEMPLATE VE DETAILROWU SEC VE ASPXGRIDMUSTERIHAREKETLERINI ICINE SURUKLE VE END TEMPLATE YAP




Gridviewda son kolumun genişliğini max yapmak
        <Columns>
            <dx:GridViewCommandColumn ShowDeleteButton="True" ShowEditButton="True" ShowNewButtonInHeader="True" VisibleIndex="0">
            </dx:GridViewCommandColumn>
            <dx:GridViewDataTextColumn FieldName="ID" ReadOnly="True" VisibleIndex="1">
                <EditFormSettings Visible="False" />
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="ADI" VisibleIndex="2" Width="100%">
            </dx:GridViewDataTextColumn>
        </Columns>



gridview detay masterda detay width sorunu once masterin altina ekle :
    <dx:ASPxGridView Width="100%" 
        <Settings HorizontalScrollBarMode="Auto" />
        <Settings VerticalScrollBarMode="Auto" />

sonra masterin son colomunun widthini %100 yap
  <dx:GridViewDataTextColumn FieldName="ADI" VisibleIndex="2" Width="100%">

sonra detaya ekle
   <dx:ASPxGridView2 Width="100%" 
        <Settings HorizontalScrollBarMode="Auto" />
        <Settings VerticalScrollBarMode="Auto" />