Click here to Skip to main content
15,893,588 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionWorking with a Gridview Edit Template at runtime. Pin
dspyank16-Apr-07 8:13
dspyank16-Apr-07 8:13 
AnswerRe: Working with a Gridview Edit Template at runtime. Pin
kubben16-Apr-07 12:56
kubben16-Apr-07 12:56 
QuestionAn AI chatbot in ASP.Net? A few snags I've run into. Pin
Caden16-Apr-07 8:05
Caden16-Apr-07 8:05 
Questionhelp me really soon guys Pin
dhananjaysonar16-Apr-07 7:18
dhananjaysonar16-Apr-07 7:18 
AnswerRe: help me really soon guys Pin
kubben16-Apr-07 13:00
kubben16-Apr-07 13:00 
QuestionHow to get previous page URL Pin
attalurisubbu16-Apr-07 5:18
attalurisubbu16-Apr-07 5:18 
AnswerRe: How to get previous page URL Pin
Guffa16-Apr-07 6:45
Guffa16-Apr-07 6:45 
QuestionUpdating a table in Dataview Pin
twhitma116-Apr-07 3:53
twhitma116-Apr-07 3:53 
Ok, I switched my code as follows:

<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>



Public Sub Page_Load(Source As Object, E As EventArgs)
If Not Page.IsPostBack Then
BindData()
End If
End Sub

Public Sub DataGrid_Edit(ByVal Source As Object, _
ByVal E As DataGridCommandEventArgs)
myInfo.EditItemIndex = E.Item.ItemIndex
BindData()
End Sub

Public Sub DataGrid_Cancel(ByVal Source As Object, _
ByVal E As DataGridCommandEventArgs)
myInfo.EditItemIndex = -1
BindData()
End Sub

Public Sub DataGrid_Update(ByVal Source As Object, _
ByVal E As DataGridCommandEventArgs)
Dim myConnection As SqlConnection
Dim myCommand As SqlCommand
Dim txtmyNewCol1 As TextBox = E.Item.Cells(1).Controls(0)
Dim txtmyNewCol2 As TextBox = E.Item.Cells(2).Controls(0)
Dim strUpdateStmt As String

strUpdateStmt = "UPDATE ToddsTable1 SET " & _
"myNewCol1 = '" & txtmyNewCol1.Text & "', " & _
"myNewcol2 = '" & txtmyNewCol2.Text & "' "

myConnection = New SqlConnection( _
"server=SQLSERVER;database=upsizedCandidate;Integrated Security=True;")
myCommand = New SqlCommand(strUpdateStmt, myConnection)
myConnection.Open()
myCommand.ExecuteNonQuery()

myInfo.EditItemIndex = -1
BindData()
End Sub

Public Sub BindData()
Dim myDataSet As New DataSet
Dim mySqlDataAdapter As SqlDataAdapter
mySqlDataAdapter = New SqlDataAdapter( _
"SELECT * FROM ToddsTable1", _
"server=SQLSERVER;database=upsizedCandidate;Integrated Security=True")
mySqlDataAdapter.Fill(myDataSet, "ToddsTable1")
myInfo.DataSource = myDataSet.Tables("ToddsTable1")
myInfo.DataBind()
End Sub




Editing ToddsTable1 from SQL Server



<asp:datagrid id="myInfo" runat="server"
="" autogeneratecolumns="False" oneditcommand="DataGrid_Edit" width="702px" oncancelcommand="DataGrid_Cancel" onupdatecommand="DataGrid_Update">

<columns>
<asp:editcommandcolumn
canceltext="Cancel"
="" edittext="Edit" updatetext="Update">
<asp:boundcolumn
datafield="myNewCol1"
="" headertext="myNewCol1">
<asp:boundcolumn
datafield="myNewCol2"
="" headertext="myNewCol2">










Everything works fine except when I click"Edit" then edit the text and click "update" it changes every cell in the column to the value I entered in the edited column. Any thoughts on how I could fix this?
Questiondate_fun_dal_mohamed_arif Pin
Hasan Ali16-Apr-07 2:59
Hasan Ali16-Apr-07 2:59 
AnswerRe: date_fun_dal_mohamed_arif Pin
_mubashir16-Apr-07 3:28
_mubashir16-Apr-07 3:28 
AnswerRe: date_fun_dal_mohamed_arif Pin
Jonathan [Darka]17-Apr-07 21:56
professionalJonathan [Darka]17-Apr-07 21:56 
Questiongridview Pin
Oga M16-Apr-07 2:43
Oga M16-Apr-07 2:43 
QuestionExcel to database table Pin
rmedo16-Apr-07 2:30
rmedo16-Apr-07 2:30 
AnswerRe: Excel to database table Pin
andyharman16-Apr-07 3:03
professionalandyharman16-Apr-07 3:03 
AnswerRe: Excel to database table Pin
Leyu16-Apr-07 4:22
Leyu16-Apr-07 4:22 
AnswerRe: Excel to database table Pin
NguyenMinhCold16-Apr-07 18:05
NguyenMinhCold16-Apr-07 18:05 
Questionhow to get tooltip for Radgrid Hyperlnik Pin
ramyasangeet16-Apr-07 2:00
ramyasangeet16-Apr-07 2:00 
AnswerRe: how to get tooltip for Radgrid Hyperlnik Pin
Sujit Gupta16-Apr-07 7:00
Sujit Gupta16-Apr-07 7:00 
QuestionCan anybody help to sort out this problem with ajax timer. Pin
Smitha Appukuttan16-Apr-07 1:49
Smitha Appukuttan16-Apr-07 1:49 
Generalhi i want dumps in webapplication with C# 2005 Pin
Christopher F16-Apr-07 1:25
Christopher F16-Apr-07 1:25 
GeneralRe: hi i want dumps in webapplication with C# 2005 Pin
GaryWoodfine 16-Apr-07 3:20
professionalGaryWoodfine 16-Apr-07 3:20 
Questiondropdownlist problem plz help me.......... Pin
pradeep kumarappagari16-Apr-07 1:14
pradeep kumarappagari16-Apr-07 1:14 
AnswerRe: dropdownlist problem plz help me.......... Pin
_mubashir16-Apr-07 2:05
_mubashir16-Apr-07 2:05 
GeneralRe: dropdownlist problem plz help me.......... Pin
pradeep kumarappagari16-Apr-07 2:18
pradeep kumarappagari16-Apr-07 2:18 
Questionasp.net SetUp Pin
xxrono16-Apr-07 0:53
xxrono16-Apr-07 0:53 

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.