473,799 Members | 3,422 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGrid Validation

Hello Gurus,
Pl. help. I need to validate a control in datagrid based on check box
selection.
Basically in a datagrid i have checkbox and textbox control for
edititemtemplat e.
If checkbox is selected i valid entry in textbox , if checkbox is not
selected , no entry should be made in textbox.
How do i write this...in csharp..

I tried this ...but not sure how to continue
HTML code looks like this
<asp:datagrid id="DataGrid1" runat="server" Width="969px"
BackColor="#AAD 2FF" AllowPaging="Tr ue"
AllowSorting="T rue" OnItemCommand=" DataGrid1_ItemC ommand"
BorderColor="Co rnflowerBlue" OnDeleteCommand ="DataGrid1_Del ete"
OnEditCommand=" DataGrid1_Edit" OnCancelCommand ="DataGrid1_Can cel"
OnPageIndexChan ged="Major_Page " AutoGenerateCol umns="False"
OnSortCommand=" Major_Sort" Font-Size="7pt" Font-Name="arial"
OnUpdateCommand ="DataGrid1_Upd ate"
Font-Names="arial">
<AlternatingIte mStyle BackColor="Whit e"></AlternatingItem Style>
<HeaderStyle BackColor="Gain sboro"></HeaderStyle>
<Columns>
<asp:TemplateCo lumn HeaderText="Maj or Code">
<ItemTemplate >
<asp:Label id=Label1 runat="server" Text='<%#
DataBinder.Eval (Container, "DataItem.cd_ma jor") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTempla te>
<asp:DropDownLi st id=cboMajorGrd style="WIDTH: 259px; HEIGHT:
23px" runat="server" Width="131px" DataSource="<%# TempDataView%>"
DataTextField=" ds_desc" DataValueField= "cd_value" SelectedIndex=" <%#
GetMajorDesc((s tring)((System. Data.DataRowVie w)Container.Dat aItem)[0])%>"
OnSelectedIndex Changed="cboMaj orGrd_SelectedI ndexChanged"
AutoPostBack="t rue">
</asp:DropDownLis t>
</EditItemTemplat e>
</asp:TemplateCol umn>
......

I tried following code in cs file...not sure how to continue..
protected void DataGrid1_ItemC ommand(Object sender, DataGridCommand EventArgs
e)
{
CheckBox chkTrans = ((CheckBox)e.It em.FindControl( "chkTranslateEd it"));
if (chkTrans != null)
{
bool bChkTrans = chkTrans.Checke d;
if (bChkTrans == true)
{
TextBox txtExpire = ((TextBox)e.Ite m.FindControl(" txtDtExpire"));
if (txtExpire !=null)
{
if (txtExpire.Text .Trim() == "")
{
lblMessage.Text ="Textbox Empty";
e.Item.Attribut es.Add("onclick ","alert('p l enter dt expire');"); --
This doesnt seem to be right!!! because it doesnt fire at all...After
validation i need cursor to go to that textbox... PL HELP..
}
}
else
{
lblMessage.Text ="Textbox not avail";
}
}
}
}

Krish
Nov 17 '05 #1
0 1393

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

Similar topics

0
1898
by: ED M. | last post by:
Hello all...I'm new to the board. I have a problem that I hope someone here might be able to solve for me. I am doing some clientside validation using Javascript. The text I am testing is within a textbox that is part of a datagrid. To complicate things, the datagrid is part of a user control. The following code is all part of the user control. The validation part of the script works fine. However, when I try to set the focus...
1
2916
by: GregM | last post by:
I have a read only datagrid that is designed to coordinate itself with textboxes. When the user clicks on a row in the datagrid, detailed data for that row is displayed for editing in the textboxes. The datagrid and textboxes are populated from the same underlying SQL Server table but using different strongly typed data adapters and datasets for display and editing. So I coordinate syncronization of the two sets of data using code. I use...
1
3015
by: Stephan Bour | last post by:
Hi, I need to validate a text box in a datagrid nested inside a datalist. All I need is to validate that any text is entered in the textbox. However, a requiredfieldvalidator would not do because I want to perform the validation only on the datagrid rows where a check box is checked. Part of the datagrid: <asp:TemplateColumn HeaderText="C #"> <ItemTemplate>
3
3002
by: Ben | last post by:
Hi, I have a page with a datagrid that you have to scroll to see. I'm using the StrengthControls SmartScroller as recommended to maintain my scroll position. Anyway, inside the datagrid I have fields that require validation. No problem, I put the validators on them and they work just fine... Except for the fact that when a user has an invalid entry and fires a validation event client side the scroll position is reset to the top of the...
2
1510
by: rodchar | last post by:
Hey all, I've got an asp.net page that has a textbox on it. The textbox has a requiredfieldvalidation associated with it. I've also got a datagrid with the edit,update,cancel links on it. When I run my app, and select the update link on the datagrid my textbox validation fires. Not sure why? Note: if i close the application and restart it it works fine. no error.
5
3248
by: Chris | last post by:
Based upon some prevoius postings on what to do for adding a 'add' row to a datagrid I utilize the footer to create the 'add' row. The only issue is that I have it sharing the 'UpDate_Command' and I use an argument to difference between an 'edit' vs. and 'add. But since I have field validation on both 'footer' and 'edit' columns I can't submit my edits since the footer validation kicks in.If I take the validation off then the both work fine...
4
3484
by: siaj | last post by:
Hello All, If some one has faced a similar issue.. My datagrid Update command is not getting fired in fact it seems that the no event fires on clicking the update link. Although the cancel and the Edit Commmand are getting fired properly. The One difference I have seen is that in the task bar ..on hovering on the link the javascript for the update link seems different. I dont know if it makes sense..
4
2977
by: David Colliver | last post by:
Hi all, I am having a slight problem that hopefully, someone can help me fix. I have a form on a page. Many items on the form have validation controls attached. Also on this form are linkbuttons which must not cause validation. I have found a setting "causeValidation" to disable the validation. Also on the page, I have a datagrid that I will edit lines on. I can click
1
2384
by: Kris | last post by:
Hi, I have a DataGrid where in each row has couple of text boxes and an update button. Each row is dynamically generated as the number of rows are not known ahead of time. When the user clicks the update button, I do a postback to capture the data entered. However I dont want to do a postback when the textboxes are empty. How do I prevent this using Clientside validation? This is a common problem and if it has been beaten to death, please...
5
2056
by: Tina | last post by:
the Edit, Update, Cancel, and Delete buttons in my datagrid are causing validation elsewhere on the page. I want to specify that these buttons should not cause validation but they have no design time property of causevalidation. How can I keep them from causing validation? Thanks, T
0
9688
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10490
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10238
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10030
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9077
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4145
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.