none
ASP.NET Web Forms DevExpress Update,Delete İşlemleri RRS feed

  • Genel Tartışma

  • .cs tarafında delete(ASPxGridView1_RowDeleting),update(ASPxGridView1_RowUpdating) gibi işlemleri yapabilmem için örnek kodları paylaşabilir misiniz ? Veritabanı tarafında yazarno(primary key),yazaradi nvarchar,yazarsoyadi(nvarchar) kolonları var.

    Mevcut kodları aşağıda paylaşıyorum.

    1-WebForm1.aspx

        <dx:ASPxGridView ID="ASPxGridView1" KeyFieldName="yazarno" OnRowCommand="ASPxGridView1_RowCommand"
                OnRowUpdating="ASPxGridView1_RowUpdating" OnRowDeleting="ASPxGridView1_RowDeleting"
                 OnRowInserting="ASPxGridView1_RowInserting"  runat="server" AutoGenerateColumns="False">
                <Settings ShowGroupPanel="True" />
    <SettingsPopup>
    <HeaderFilter MinHeight="140px"></HeaderFilter>
    </SettingsPopup>
                <SettingsSearchPanel Visible="True" />
                <Columns>
                    
                    <dx:GridViewCommandColumn ShowDeleteButton="True" ShowEditButton="True" ShowNewButtonInHeader="True" VisibleIndex="0">
                    </dx:GridViewCommandColumn>
                    <dx:GridViewDataTextColumn Caption="ID" FieldName="yazarno" VisibleIndex="1" Visible="False">
                    </dx:GridViewDataTextColumn>
                    <dx:GridViewDataTextColumn Caption="Ad" FieldName="yazaradi" VisibleIndex="2">
                    </dx:GridViewDataTextColumn>
                    <dx:GridViewDataTextColumn Caption="Soyadı" FieldName="yazarsoyadi" VisibleIndex="3">
                    </dx:GridViewDataTextColumn>
                </Columns>
            </dx:ASPxGridView>



            <asp:SqlDataSource ID="SqlDataSource1" runat="server">
              
               
              
            </asp:SqlDataSource>

    2-WebForm1.aspx.cs

    using DevExpress.Web;
    using System;
    using System.Collections.Generic;
    using System.Configuration;
    using System.Data;
    using System.Data.OleDb;
    using System.Data.SqlClient;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    namespace WebApplication4
    {
        public partial class WebForm1 : System.Web.UI.Page
        {
            SqlConnection con;
            string sqlconn;
            protected void Page_Load(object sender, EventArgs e)
            {


                if (!IsPostBack)
                {
                    GridViewDoldur();
                }
               




           
            }

            void GridViewDoldur()
            {
                DataTable dtbl = new DataTable();

                connection();
                con.Open();
                SqlDataAdapter sqlDa = new SqlDataAdapter("SELECT *FROM yazar",con);
                sqlDa.Fill(dtbl);
                if (dtbl.Rows.Count >0)
                {
                    ASPxGridView1.DataSource = dtbl;
                    ASPxGridView1.DataBind();
                }
              



            }

            private void connection()
            {
                sqlconn = ConfigurationManager.ConnectionStrings["deneme3ConnectionString"].ConnectionString;
                con = new SqlConnection(sqlconn);
            }
     protected void ASPxGridView1_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e){

    }

     protected void ASPxGridView1_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e){

    }


    29 Ekim 2019 Salı 19:58