Click here to Skip to main content
16,016,535 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: is it good to use : SqlDataSource Pin
goradaranaresh26-Jan-07 2:41
goradaranaresh26-Jan-07 2:41 
GeneralRe: is it good to use : SqlDataSource Pin
Amit Kumar G26-Jan-07 3:40
Amit Kumar G26-Jan-07 3:40 
Questionexecuting code when the user closes the web page Pin
dipanddump25-Jan-07 12:56
dipanddump25-Jan-07 12:56 
AnswerRe: executing code when the user closes the web page Pin
Christian Graus25-Jan-07 16:10
protectorChristian Graus25-Jan-07 16:10 
AnswerRe: executing code when the user closes the web page Pin
Artem Kustikov25-Jan-07 21:08
Artem Kustikov25-Jan-07 21:08 
QuestionPop up menu Pin
James_Marsters25-Jan-07 12:40
James_Marsters25-Jan-07 12:40 
AnswerRe: Pop up menu Pin
Christian Graus25-Jan-07 16:14
protectorChristian Graus25-Jan-07 16:14 
QuestionI Have Problem with gridview Update /delete (using /Asp.net,VB.net) Pin
see_me_honey25-Jan-07 9:18
see_me_honey25-Jan-07 9:18 
Hey:
I am facing problem in my asp.net/vb.net 2.0 program. i want to Select,Add, Delete,Edit,Update,Cancel. Ineteresting thing is that Event is working except Update,Delete Gridview Without inserted data into database.
my requirement is to add multiple Items in gridview and after successful data entry and in last, i want to save gridview all rows at once, not one by
one.

i place two/three textboxes followed by add button which will add textbox values in to gridview (Note: Not in Database), if due to any entry error, i simply want to edit,update/delete inserted rows from the gridview.
Note: Gridview EditColumns , i add two boundfields and then converted to Templatefiled and i have unchecked auto generate fields becoz i dont wana any extra fields. finally when i press Post button it will post all gridview data rows once and Problem is update/delete datagrid before post the data into the database, may be update/delete i will add more values in gridview and then post. i think enough description to tell someone wat i actually wants. in advance thankyou to help me out.
Note: just right the code on request area and reply me back. once again thank you. remember i am new to asp.net and vb.net and please do it only in asp/vb.net

i am pasting my code below, please help me out how i can do this on fly,please dont forget to lable the code.

Here is my Code
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.Sql
Imports System.Data.SqlTypes
Imports System.Configuration
Imports System.Collections


Partial Class _Default
Inherits System.Web.UI.Page



Dim dt As Data.DataTable
Dim ds As New Data.DataSet
Dim ds1 As New Data.DataSet
Dim dr As Data.DataRow
Dim dc As New Data.DataColumn
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim SqlCon As New SqlConnection
Dim SqlCom As SqlCommand


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
SqlCon.ConnectionString = System.Configuration.ConfigurationManager.AppSettings.Get("alisons")


'SqlConnection("Data Source=dell;Initial Catalog=alisons;Integrated Security=True")
'cn.Open("Dsn=alisons; uid=alisons; pwd=alisons;")

dt = New Data.DataTable
ds = New Data.DataSet
If Not IsPostBack Then
Session("ds") = ds
ds.Tables.Add(dt)
ds.Tables(0).Columns.Add(New Data.DataColumn("Code"))
ds.Tables(0).Columns.Add(New Data.DataColumn("Name"))
ds.AcceptChanges()

End If
End Sub



Sub fillGrid()
ds1 = CType(Session("ds"), Data.DataSet)
GridView1.DataSource = ds1.Tables(0)
GridView1.DataBind()
End Sub


Protected Sub cmdAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdAdd.Click
ds1 = CType(Session("ds"), Data.DataSet)

dr = ds1.Tables(0).NewRow()
dr("Code") = Txt_Code.Text
dr("Name") = txt_Name.Text

ds1.Tables(0).Rows.Add(dr)
ds1.AcceptChanges()

fillGrid()
Txt_Code.Text = ""
txt_Name.Text = ""

End Sub

Protected Sub GridView1_PageIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.PageIndexChanged
fillGrid()
End Sub

Protected Sub GridView1_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles GridView1.PageIndexChanging
GridView1.PageIndex = e.NewPageIndex
End Sub

Protected Sub GridView1_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GridView1.RowCancelingEdit
GridView1.EditIndex = -1
fillGrid()
End Sub

Protected Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridView1.RowDeleting
' delete row
End Sub

Protected Sub GridView1_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GridView1.RowEditing
GridView1.EditIndex = e.NewEditIndex
fillGrid()
End Sub
Protected Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridView1.RowDeleting
' Facing Problem Here

End Sub


Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating
' Facing Problem Here

'ds1 = CType(Session("ds"), Data.DataSet)
Dim GRow0 As GridViewRow = GridView1.Rows(e.RowIndex)
Dim GRow1 As GridViewRow = GridView1.Rows(e.RowIndex)
If Not GRow0 Is Nothing And Not GRow1 Is Nothing Then
Dim t0 As TextBox = GRow0.FindControl("texcol0")
Dim t1 As TextBox = GRow1.FindControl("texcol1")

'T = GRow.FindControl("Code")
If Not t0 Is Nothing And Not t1 Is Nothing Then
Response.Write("The Col0 is Entered " + t0.Text)
Response.Write("The Col1 is Entered " + t1.Text)

'dr = ds1.Tables(0).NewRow()
'dr("Code") = t0.Text
'dr("Name") = t1.Text

'ds1.Tables(0).Rows.Add(dr)
ds1.AcceptChanges()
'fillGrid()
End If
End If
End Sub

Protected Sub btnPost_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPost.Click
'Dim ds1 As DataSet = CType(Session("ds"), DataSet)
'Dim datasource1 As SqlDataSource = New SqlDataSource()

Dim paramCode As String
Dim paramName As String
Dim sqlstr As String
Dim dr As DataRow
Dim datasource1 As SqlDataSource
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
datasource1 = New SqlDataSource()

ds1 = CType(Session("ds"), Data.DataSet)

cn.Open("DSN=alisons; uid=alisons; pwd=alisons;")
Response.Write(cn)
If cn.State = 1 Then
'cn.BeginTrans()
For Each dr In ds1.Tables(0).Rows
paramCode = Trim(dr("Code"))
paramName = Trim(dr("Name"))
sqlstr = "INSERT INTO Tbl_LOV(Code, Name) VALUES ('" + paramCode + "','" + paramName + "')"
cn.Execute(sqlstr)
Next
'cn.CommitTrans()
Response.Write("Inserted")
End If
End Sub

Protected Sub btnExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExit.Click
GridView1.EditIndex = -1
End Sub

Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged

End Sub
End Class


-----------------------------------------------------------------------------

Regards,
Ricky.
QuestionBack button problem Pin
nour12325-Jan-07 9:15
nour12325-Jan-07 9:15 
AnswerRe: Back button problem Pin
Christian Graus25-Jan-07 16:29
protectorChristian Graus25-Jan-07 16:29 
GeneralRe: Back button problem Pin
nour12325-Jan-07 23:45
nour12325-Jan-07 23:45 
GeneralRe: Back button problem Pin
Christian Graus26-Jan-07 10:01
protectorChristian Graus26-Jan-07 10:01 
GeneralRe: Back button problem Pin
nour12326-Jan-07 11:18
nour12326-Jan-07 11:18 
GeneralRe: Back button problem Pin
Christian Graus26-Jan-07 22:38
protectorChristian Graus26-Jan-07 22:38 
GeneralRe: Back button problem Pin
nour12327-Jan-07 3:16
nour12327-Jan-07 3:16 
AnswerRe: Back button problem Pin
linpihong25-Jan-07 19:49
linpihong25-Jan-07 19:49 
GeneralRe: Back button problem Pin
nour12325-Jan-07 23:45
nour12325-Jan-07 23:45 
GeneralRe: Back button problem Pin
Dinesh G Jethva129-Jan-07 1:55
Dinesh G Jethva129-Jan-07 1:55 
QuestionDataList and border-collapse Pin
RX Maverick25-Jan-07 9:07
RX Maverick25-Jan-07 9:07 
AnswerRe: DataList and border-collapse Pin
klawipo25-Jan-07 9:30
klawipo25-Jan-07 9:30 
GeneralRe: DataList and border-collapse Pin
RX Maverick25-Jan-07 9:50
RX Maverick25-Jan-07 9:50 
GeneralRe: DataList and border-collapse Pin
klawipo25-Jan-07 9:58
klawipo25-Jan-07 9:58 
Questionwindows does not have IIS Pin
sanaziuse25-Jan-07 8:07
sanaziuse25-Jan-07 8:07 
AnswerRe: windows does not have IIS Pin
Goalie3525-Jan-07 8:27
Goalie3525-Jan-07 8:27 
AnswerRe: windows does not have IIS Pin
Guffa25-Jan-07 9:39
Guffa25-Jan-07 9:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.