473,385 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

DATAGRID PROBLEM

First When I Bind my datagrid It returns --Unisex-- value for my
GENDER_NAME field. When I click Edit , Write UNI to update UNÝSEX value and
Click Update button i catch

UPDATE TBL_GENDER SET GENDER_NAME='Unisex' WHERE GENDER_ID=1
with response.write ..

Why it doesnt return me current value of my Text1 texbox item. What is the
problem?


<asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 190px; POSITION:
absolute; TOP: 195px"
runat="server" AutoGenerateColumns="False">

<Columns>

<asp:editcommandcolumn edittext="Edit" canceltext="Cancel"
updatetext="Update" itemstyle-wrap="false"

ItemStyle-Width="100px" />

<asp:TemplateColumn>

<EditItemTemplate >
<asp:TextBox ID="Text1" Runat=server Text='<%#
DataBinder.Eval(Container, "DataItem.GENDER_NAME") %>'>

</asp:TextBox>

<asp:TextBox ID="Label1" Runat=server Visible=False Text='<%#
DataBinder.Eval(Container, "DataItem.GENDER_ID") %>'>

</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>

</Columns>
</asp:DataGrid>

Private Sub DataGrid1_EditCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
DataGrid1.EditCommand

Me.DataGrid1.EditItemIndex = e.Item.ItemIndex

DataGrid1.DataBind()

End Sub



Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
DataGrid1.UpdateCommand

Dim sorgu As String

Dim strDestination As String = CType(e.Item.FindControl("Text1"),
TextBox).Text

Dim strID As String = CType(e.Item.FindControl("Label1"), TextBox).Text

Dim baglantim1 As New SqlClient.SqlConnection

sorgu = "UPDATE TBL_GENDER SET GENDER_NAME='" & strDestination & "' WHERE
GENDER_ID=" & strID

Response.Write(sorgu)

Response.End()

End Sub


Apr 29 '06 #1
1 945
On Sat, 29 Apr 2006 14:32:07 +0300, "Savas Ates" <in da club> wrote:
DataGrid1.DataBind()
This line looks suspect, calling databind will often end editing etc. It
will also reset the viewstate and postback handling on the datagrid.

Also double check that you don't call DataBind() every time you load the
page, only when you first load the page. eg:

If Not Page.IsPostBack() Then PopulateDatagrid()

Where PopulateDatagrid() is the method that will query the database and
call databind.

sorgu = "UPDATE TBL_GENDER SET GENDER_NAME='" & strDestination & "' WHERE
GENDER_ID=" & strID


As a side note this code is potentualy unsafe due to sql injection, see
http://www.codeproject.com/cs/databa...ionAttacks.asp for an
explaination and solution.
Apr 30 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jeff | last post by:
IDE: VS 2003 :NET OS: XP Pro My app have a form with a tab-control on it. The tab-control have 2 tabpages. One of the tabpages displays a datagrid, and the other tabpage displays details (order...
1
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls...
0
by: Richard Ryerson | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls (watch...
9
by: tshad | last post by:
How do I find (and set) a couple of labels in the Footer after a DataGrid is filled? I have a bunch of DataGrids that get displayed nested inside a DataList. The datagrid looks like: ...
0
by: optimizeit | last post by:
What I am attempting to do is import an Excel Workbook and display the worksheets in a datagrid dynamically. I am very close to getting this to work. I have to this point successfully imported a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.