|
Subject:
|
Datagrid Problem
|
|
Posted By:
|
monika.vasvani
|
Post Date:
|
9/22/2006 2:26:31 AM
|
HI EVERY1
I AM USING DATAGRID CONTROL IN MY APPLICATION.FIRST COLUMN CONTAINS RADIO BUTTONS.WHEN I CHECKED ON RADIO BUTTON,I WANT TO DELETE THAT CORRESPONDING ROW BUT WITHOUT DELETING FROM THE DATABASE.hOW IS IT POSSIBLE?IF U HAVE ANY IDEA,PLS REPLY ME.IT'S URGENT.
TYHANKS MONIKA
|
|
Reply By:
|
Jose Fidalgo
|
Reply Date:
|
9/22/2006 6:58:52 AM
|
You must cover grid and verify if RADIO BUTTON this false, something of this: 'VERY IMPORTANT the radio button need configure AutoPostback=true Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not Page.IsPostBack Then Dim conn As New SqlConnection("Integrated Security=SSPI;Persist Security Info=False;User ID=Sacoor/jose fidalgo;Password=jcf2004.,;Initial Catalog=Loja1601;Data Source=PC03-INFO") conn.Open() Dim st As String = "select ref,codigo=codpor from u_promocao where ref like '2%'" Dim adapt As New SqlDataAdapter(st, conn) Dim ds As New DataSet adapt.Fill(ds, "Promo") Session("mytab") = ds.Tables("Promo") Me.DataGrid1.DataSource = Session("mytab") Me.DataBind()
Else Dim litem As DataGridItem Dim tabaux As New DataTable With tabaux.Columns .Add("ref", GetType(System.String)) .Add("codigo", GetType(System.String)) End With
Dim myrow As DataRow
For Each litem In Me.DataGrid1.Items Dim rd As New RadioButton rd = CType(litem.FindControl("radio"), RadioButton) If rd.Checked = False Then
myrow = tabaux.NewRow myrow("ref") = litem.Cells(1).Text myrow("codigo") = litem.Cells(2).Text tabaux.Rows.Add(myrow) End If
Next Dim cloneTable As DataTable Dim mr As DataRow CType(Session("mytab"), DataTable).Clear() For Each mr In tabaux.Rows CType(Session("mytab"), DataTable).ImportRow(mr) Next Me.DataGrid1.DataSource = Session("mytab") Me.DataGrid1.DataBind()
End If End Sub
I wait that it helps
|