473,398 Members | 2,427 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,398 software developers and data experts.

EditCommandColumn and Data Grid Help

Please see the class file and the asp file. I want to validate two text
fields when the update is clicked. As you guys know, when the edit is
clicked, it changes to update and cancel.
I want to validate on update click by a javascript. If anyone can tell
me, how to pass the
values to the javascript that will be great. This is done VS2003.

Part of the class file

public void DataGrid2_Edit(Object sender, DataGridCommandEventArgs e)
{
TableCell cell = (TableCell) e.Item.Controls[0];
System.Web.UI.WebControls.LinkButton img =
(System.Web.UI.WebControls.LinkButton ) cell.Controls[0];
img.Attributes.Add("onclick",
"javascript:confirm_update();");
DataGrid2.EditItemIndex = (int)e.Item.ItemIndex;
BindGrid();

}
public void DataGrid2_Cancel(Object sender, DataGridCommandEventArgs
e)
{
DataGrid2.EditItemIndex = -1;
BindGrid();
}

public void DataGrid2_Update(Object sender, DataGridCommandEventArgs
e)
{
string col1text = e.Item.Cells[1].Text;
string col2text = ((System.Web.UI.WebControls.TextBox)
e.Item.Cells[2].Controls[0]).Text;
string col3text = ((System.Web.UI.WebControls.TextBox)
e.Item.Cells[3].Controls[0]).Text;

}


ASP PAGE:

</style>
<script language="javascript">

function confirm_update()
{

//alert("test" + x);
alert("hello" + x);
}
</script>
</HEAD>
<BODY>
<form id="Form1" method="post" runat="server">
<asp:datagrid id="DataGrid2" runat="server"
AutoGenerateColumns="false" OnUpdateCommand="DataGrid2_Update"
OnCancelCommand="DataGrid2_Cancel" OnEditCommand="DataGrid2_Edit"
HeaderStyle-BackColor="#aaaadd"
Font-Size="8pt" Font-Name="Verdana" CellPadding="3" BorderWidth="1"
BorderColor="black"
onselectedindexchanged="DataGrid2_SelectedIndexCha nged">
<Columns>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update"
CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn>
<asp:BoundColumn HeaderText="COL1" DataField="col1text"
ReadOnly="True" />
<asp:BoundColumn HeaderText="COL2 DataField="col2text" />
<asp:BoundColumn HeaderText="COL3" DataField="col3text" />
</Columns>
</asp:datagrid>
</form>
</BODY>
</HTML>

Oct 9 '06 #1
0 1020

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

Similar topics

5
by: Maziar Aflatoun | last post by:
Hi everyone, Does anyone know how I can add a CSS (Ex. button1 ) to the following Edit button is ASP .NET? <asp:EditCommandColumn ButtonType="PushButton" EditText="Edit" CancelText="Edit"...
2
by: Bonj | last post by:
Hi I've been following the example on http://aspnet.4guysfromrolla.com/articles/071002-1.3.aspx and no matter what I do, i can't get the DataGrid1_EditCommand event handler to fire. Could...
4
by: RobS | last post by:
Can anyone answer this question: How can I disable validation when edit column update button is pressed. Can it be done for the whole grid? Regards, Robert
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...
2
by: Ron | last post by:
Hello, I am trying to create a page that pulls class rosters from an SQLServer database. The roster table definition is: emp_id(pk, fk), sec_id(pk, fk), reg_date and reg_status. Status can be...
7
by: needin4mation | last post by:
I have this in my DataGrid's ItemCreated event: TableCell myChangeCell = e.Item.Cells; LinkButton myChangeButton = (LinkButton) myTableCell.Controls; myChangeButton.Text="Hello!"; I am trying...
4
by: Sourav Dutta Gupta | last post by:
I want to change the "scr" like src='images/Edit.ICO' to src='images/XYZ.ICO' dynamically based on some condition. My EditCommandColumn: <asp:EditCommandColumn ButtonType="LinkButton"...
6
by: Scott McDaniel | last post by:
I'm using Visual Studio 2005 with the .NET 2.0.50727 framework, and we're using the standard Datagrid control bound to a SQL Server. We have two groups of users - "full edit" users, and "view...
0
by: Ian | last post by:
Hi I have used the following code to essentially late bind an EditCommandColumn to my datagrid in ASP.NET. EditCommandColumn ec = new EditCommandColumn(); ec.ButtonType =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.