DATAGRID,DATALIST part1




















DATAGRID,DATALIST OPERATION IN VB.NET


 


DATALIST


   Protected Sub DataList1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs)
Handles DataList1.ItemCommand


        Try


 


            If
(e.CommandName = "upall") Then


 


 


                obj.setconnection()


 


                obj.openconnection()


 


                For
Each row As DataListItem In DataList1.Items


 


 


                    Dim
lblsub As Label = row.FindControl("lblsub")


                    Dim
txtmark As TextBox = row.FindControl("txtmarks")


                    Dim
lblreg As Label = row.FindControl("lblreg")


                    Dim
ch As CheckBox = row.FindControl("Ch")


 


 


 


                    If
(ch.Checked = True) Then


 


                        If Not (txtmark.Text
= "") Then


 


 


 


                            If (txtmark.Text = "0") Then


                                txtmark.Text = "''"


                            End If


                            Dim strsub As String = "Update " + ddldept.SelectedValue + "
set "
& lblsub.Text & "=" & txtmark.Text
& " where Reg_No='"
+ lblreg.Text + "'"


 


 


                            obj.executequery(strsub)


                        End If


 


 


                    End
If


 


 


 


                Next


                ' DataList1.Visible
= False


                DataGrid4.Visible = True


                lblvalue.Text
= ""


 


                marklistdetails()


                obj.closeconnection()


            


                TabContainer1.ActiveTabIndex = 1


 


            End
If


 


 


        Catch
ex As Exception


          


        End Try


    End Sub


 


----------------------------//DATAGRID


Protected Sub DataGrid5_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs)
Handles DataGrid5.ItemCommand


 


 


     


        Try


 


            'If (e.CommandName = "upall")
Then


 


 


            obj.setconnection()


 


            obj.openconnection()


 


            For
Each row As DataGridItem In DataGrid5.Items


 


 


                Dim
lblsub As Label = e.Item.FindControl("lblsub")


                Dim
txtmark As TextBox = e.Item.FindControl("txtmarks")


                Dim
lblreg As Label = e.Item.FindControl("lblreg")


                Dim
ch As CheckBox = e.Item.FindControl("Ch")


 


 


 


                If
(ch.Checked = True) Then


 


 


                    Dim
strsub As String = "Update " + ddldept.SelectedValue
+ " set " & lblsub.Text & "="
& txtmark.Text & "
where Reg_No='"
+ lblreg.Text
+ "'"


 


 


                    obj.executequery(strsub)


 


 


 


                End
If


 


 


 


            Next


            obj.closeconnection()


 


            'End If


 


 


        Catch
ex As Exception


 


        End Try


    End Sub


 


 


 






No comments:

Post a Comment

.Net References