نمایش نتایج 1 تا 4 از 4

نام تاپیک: نوشتن کد برای دکمه Delete در Grid

  1. #1

    نوشتن کد برای دکمه Delete در Grid

    بچه ها من یک DataGrid با aSP.NET درست کرده ام و می خواهم کدی را بنویسم که هر گاه بر روی یک دکمه کلیک کردم ان رکورد حذف شود.(بچه ها اگر امکان داره کد را در قسمت ASPX.VB برایم بنویسید.

  2. #2
    کاربر دائمی
    تاریخ عضویت
    بهمن 1381
    محل زندگی
    ایران - تهران
    پست
    2,342
    به صفحه ی زیر مراجعه کنید. هر چیزی که شما در مورد دیتاگرید و کار با داده ها می خواهید دارد با کلی مثال به انواع زبانهای مختلف:
    http://samples.gotdotnet.com/quickst...ataaccess.aspx

  3. #3
    اقای نصیری عزیز سلام
    لطفا کد لازم جهت حذف در DataGrid را برای من در قسمت Asp.Vb بنویسید با سپاس فراوان

  4. #4
    کاربر دائمی
    تاریخ عضویت
    بهمن 1381
    محل زندگی
    ایران - تهران
    پست
    2,342
    با سلام

    این سورس وی بی برای شما :


    <%@ Import Namespace="System.IO" %>
    <%@ Import Namespace="System.Data" %>
    <html>
    <script language="VB" runat="server">

    Sub Page_Load(Src As Object, E As EventArgs)
    If Not (IsPostBack)
    DataLoad("isbn")
    End If
    End Sub

    Sub DataLoad(parmsort as string)
    Dim ds As New DataSet
    Dim FS As New FileStream(Server.MapPath("/experiments/data/books.xml"), FileMode.Open)
    ds.ReadXml(FS)
    Dim dv1 as new dataview(ds.Tables(0))
    dv1.Sort = parmsort
    'dv1.RowFilter = "city='Albany'"
    MyDataGrid.DataSource = dv1
    MyDataGrid.DataBind()
    FS.close()
    END SUB

    Sub DataSort(Src As Object, E As DataGridSortCommandEventArgs)
    ' Bug if we sort, then Edit Item Becomes Wrong
    IF MyDataGrid.EditItemIndex=-1 THEN
    DataLoad(e.sortexpression)
    ELSE
    response.write ("Can't sort until editing is done!")
    END IF
    End Sub

    Sub DataDelete(Sender As Object, E As DataGridCommandEventArgs)
    DIM deletekey as string
    IF MyDataGrid.EditItemIndex=-1 THEN
    deletekey=MyDataGrid.DataKeys(CInt(E.Item. ItemIndex))
    response.write ("deleted " & deletekey)
    ELSE
    response.write ("Can't delete until editing is done!")
    END IF
    END SUB


    Sub DataEdit(Sender As Object, E As DataGridCommandEventArgs)
    DIM editkey as string
    MyDataGrid.EditItemIndex = Cint(E.Item.ItemIndex)
    editkey=MyDataGrid.DataKeys(CInt(E.Item.It emIndex))
    'response.write ("To Be Edited" & editkey)
    DataLoad("")
    End Sub

    Sub DataCancel(Sender As Object, E As DataGridCommandEventArgs)
    MyDataGrid.EditItemIndex = -1
    response.write ("edit was cancelled")
    DataLoad("")
    End Sub

    Sub DataUpdate(Sender As Object, E As DataGridCommandEventArgs)
    DIM editkey as string
    MyDataGrid.EditItemIndex = -1
    editkey = MyDataGrid.DataKeys(CInt(E.Item.ItemIndex& #41;)
    response.write ("To Be Updated " & editkey)
    DataLoad("")
    ' howmanycols = E.Item.Cells.Count
    End Sub

    </script>

    <body>

    <h3><font face="Verdana">The Best Books Ever</font>
    <span runat="server" id="MySpan"/></h3>

    <form runat="server">
    <ASP:DataGrid id="MyDataGrid" runat="server"

    AllowSorting="true"
    OnSortCommand="DataSort"
    OnDeleteCommand="DataDelete"
    OnEditCommand="DataEdit"
    OnCancelCommand="DataCancel"
    OnUpdateCommand="DataUpdate"

    DataKeyField="isbn"

    Width="100%"
    BackColor="white"
    BorderColor="black"
    ShowFooter="false"
    CellPadding=3
    CellSpacing="0"
    Font-Name="Verdana"
    Font-Size="8pt"
    Headerstyle-BackColor="lightblue"
    Headerstyle-Font-Size="10pt"
    Headerstyle-Font-Style="bold"
    MaintainState="true"
    >



    <Columns>
    <asp:ButtonColumn Text="Delete Book" CommandName="Delete"/>

    <asp:EditCommandColumn EditText="Edit" CancelText="Cancel" UpdateText="Update" ItemStyle-Wrap="false"/>
    </columns>
    </ASP:DataGrid>

    </form>

    </body>
    </html>



    این هم اون فایل xml که ازش داده ها خوانده می شود (بعنوان دیتابیس) :

    <books>
    <book>
    <isbn>0070653623</isbn>
    <author>Jack Trout, Steve Rivkin</author>
    <title>The Power of Simplicity</title>
    <category>selfhelp</category>
    <comments>A Real Fun Read</comments>
    </book>

    <book>
    <isbn>0887306667</isbn>
    <author>Al Reiss, Jack Trout</author>
    <title>22 Immutable Laws of Marketing</title>
    <category>marketing</category>
    <comments>This team offers more profound advice about creating world class marketing campaigns that will be viable for a hundred years.</comments>
    </book>

    <book>
    <isbn>0887309372</isbn>
    <author>Al Reiss, Laura Reiss</author>
    <title>22 Immutable Laws of Branding</title>
    <category>marketing</category>
    <comments>This book is great for people who used 22 Immutable Laws of Marketing to build a brand and now want to strengthen that brand.</comments>
    </book>

    <book>
    <isbn>0679757651</isbn>
    <author>Tom Peters</author>
    <title>Circle of Innovation</title>
    <category>marketing</category>
    <comments>His most recent book is his best by far!</comments>
    </book>

    <book>
    <isbn>0884270610</isbn>
    <author>Eli Goldthrait</author>
    <title>The Goal</title>
    <category>management</category>
    <comments>Advocate of Theory of Constraints as applied to managment and optimization.</comments>
    </book>

    <book>
    <isbn>068485600X</isbn>
    <author>Jeff Cox, Howard Stevens</author>
    <title>Selling the Wheel</title>
    <category>management</category>
    <comments>Excellent Treatise/Novel on the entire Sales Cycle</comments>
    </book>

    <book>
    <isbn>0672316498</isbn>
    <author>Alan Cooper</author>
    <title>The Inmates Are Running The Asylum</title>
    <category>management</category>
    <comments>The father of Visual Basic and creator of the new art of Interaction Design - very valuable in designing websites. Basically the worlds most cutting edge thinker in User Interface design aimed at simplifying software use.</comments>
    </book>

    </books>

تاپیک های مشابه

  1. حذف پیغام هنگام اجرای کوئری delete
    نوشته شده توسط AHMAD-AHMAD در بخش Access
    پاسخ: 4
    آخرین پست: سه شنبه 02 مرداد 1386, 14:33 عصر
  2. data grid & delete
    نوشته شده توسط khomar در بخش برنامه نویسی در 6 VB
    پاسخ: 27
    آخرین پست: دوشنبه 10 مهر 1385, 19:40 عصر
  3. Delete کردن فولدر و زیر فولدرها
    نوشته شده توسط ehsan_ansaripoor در بخش برنامه نویسی در 6 VB
    پاسخ: 7
    آخرین پست: سه شنبه 17 آبان 1384, 19:15 عصر
  4. Delete کردن تمامی داده ها
    نوشته شده توسط فاطمه هاشمیان در بخش C#‎‎
    پاسخ: 5
    آخرین پست: سه شنبه 17 خرداد 1384, 21:26 عصر

قوانین ایجاد تاپیک در تالار

  • شما نمی توانید تاپیک جدید ایجاد کنید
  • شما نمی توانید به تاپیک ها پاسخ دهید
  • شما نمی توانید ضمیمه ارسال کنید
  • شما نمی توانید پاسخ هایتان را ویرایش کنید
  •