Data Controls :: Validation For Dynamic Gridview Cells
Dec 8, 2013
In my gridview i have
I have a dropdownlist with tables. if i select the table, based on the columns the gridview displays.
One table contains 9 columns and other contains 40 columns... for example....see the below.
Insert/Edit RoleUID RoleID Role Desc ....etc columns
Here RoleId, role are mandatory fields... i am making those two with "*" red color. but if i click on the "INSERT" then i need to get a alert msg that the roleid is mandatory.. you should enter in interger value, and if "role" is null then same like "Role is mandatory... plz enter character value"
I don't have any template fields in the gridview. i make autogeneratecolumns=true in my grid.
I need validation for the dynamic gridview cell... where there is no columns fixed...
I used the below code ... for INSERT
for (int j = 3; j < cellCount; j++) {
View 1 Replies
Similar Messages:
Aug 3, 2010
I generate dynamic grids based on a count value returned from some DB tables. the code for it goes like this : I give and Id to each grid that is generated.
if (myDataList1.Count >= 1)
{
for (int i = 0; i < myDataList1.Count; i++)
{
//retrieving the exact i count from pageload
ViewState.Add("newCount", i);
//creating the dynamic grid with its corresponding gridview properties.
grvDynamic = new GridView();
grvDynamic.ID = "GridView" + (i+3);
grvDynamic.AutoGenerateColumns = false;
grvDynamic.RowCreated += GridViewRowCreated;
grvDynamic.RowDataBound += grvDynamic_RowDataBound;
//adding bound field columns to retrieve data from stored proc
BoundField metric = new BoundField();
metric.HeaderText = "Goal ";
metric.DataField = "metric";
grvDynamic.Columns.Add(metric);
BoundField mtd = new BoundField();
mtd.HeaderText = "MTD";
mtd.DataField = "value_MTD";
grvDynamic.Columns.Add(mtd);
BoundField goal = new BoundField();
goal.HeaderText = "Tier Level Achieved";
goal.DataField = "value_goal";
goal.HeaderStyle.Width = Unit.Percentage(10);
grvDynamic.Columns.Add(goal);
BoundField you1 = new BoundField();
you1.HeaderText = "Month End";
you1.DataField = "firstLevel_you";
grvDynamic.Columns.Add(you1);
BoundField you2 = new BoundField();
you2.HeaderText = "Month End";
you2.DataField = "secondLevel_you";
grvDynamic.Columns.Add(you2);
ButtonField singleClick = new ButtonField();
singleClick.CommandName = "clickHyperlink";
singleClick.Visible = false;
grvDynamic.Columns.Add(singleClick);
BoundField metricId = new BoundField();
metricId.HeaderText = "Metric Id";
metricId.DataField = "metricID";
metricId.Visible = true;
grvDynamic.Columns.Add(metricId);
//binding the gridview to data.
grvDynamic.DataSource = data;
grvDynamic.DataBind();
grvDynamic.Columns[5].Visible = false;
}
}
protected void grvDynamic_RowDataBound(object sender, GridViewRowEventArgs e)
{
//this basically gets the metric Id's of rows with the ishyperlink flag set to 'Y'. I need to make these particular cells clickable var isClickable = (from md in myDataList3 where md.IsHyperLinkFlag == 'Y' &&
md.value_MTD != null select md.metricID).ToList();
if (e.Row.RowType == DataControlRowType.DataRow)
{
// Get reference to button field in the gridview.
LinkButton _singleClickButton = (LinkButton)e.Row.Cells[5].Controls[0];
if (isClickable.Contains(Convert.ToInt32(e.Row.Cells[6].Text)))
{
e.Row.Cells[1].Style["cursor"] = "hand";
e.Row.Cells[1].Style["color"] = "blue";
e.Row.Cells[1].Style["textdecoration"] = "Underline";
e.Row.Cells[1].Attributes.Add("onClick", "window.location ='../HeaderPages/page2.aspx' ");
}
}
}
This code works perfectly fine , depending on the ishyperlink flag in the database...specific cells in the grid are made clickable and then redirected to page2.aspx My Issue: I need to capture which specific cell in which specific grid the user has clicked. store some information in sessions based on the cell clicked and use that information in page2.aspx.
View 5 Replies
Feb 21, 2011
There are two fields and a button :
1)text box for the caption.
2)drop down list to select the control to be added.
3)button is an ADD button .
when the "ADD" button is clicked the text entered in the "caption" text box has to appear in the first cell of the first row in the table and the control selected from the dropdown list has to be added to the second cell of the same row. similarly many such captions and controls have to be dynamically addded to the successive rows of the table as per user selection ( note: the previously selected control and caption label must persist on furthur selections .
how do i go about the adding controls and the text into the table part ?
View 5 Replies
Aug 18, 2015
As per you sample : [URL] ...
How do I add maximum rows that can be added ?
View 1 Replies
Apr 1, 2011
I have a loop which creates for each item ID a Dynamic created checkboxlist control
how do I create a dynamic validation control on a dynamic checkboxlist?
View 3 Replies
Feb 25, 2016
With reference to the following link: [URL] .....
I want to save data to a different table. My save is working fine but the challenge is that it saves empty cells as well.I will like to save only QTyDelivered cell with value. Any empty QTyDelivered cell should be ignored (which means the row of QTyDelivered cell that is empty will not be saved) .How can i achieve this?
View 1 Replies
Jul 17, 2013
I have a form that contains a asp:Table and it contains 2 rows with 6 columns.
Also on my form is a gridview. It contains one row with 6 columns. (see pic)
I'd like to see if I can format both so that they appear to have the same over-all width and cell width too.
I'd like to know if it's possible to do this in the source view - rather than programmatically.
In the pic, the top is the grid view and underneath is the table.
View 6 Replies
Jun 2, 2013
In datagridview records as follows;
Date Session
6-jun 1 6-jun 2 6-jun 3 6-jun 4
from the above datagridview records i want as follows
Date Session
1
2
6-jun 3
4
for that how can i merge the date in datagridview make it into single column.
Note it is windows application.
View 1 Replies
Nov 16, 2010
CellPadding only applies the padding to the header row. CssClass in Gridview, RowStyle or EditRowStyle has no effect.
View 2 Replies
May 4, 2010
i have a gridview in my website and i want to merge two cell of that in same column but in different row , for example i have a data about tours in an agency , now i define a tour that has two hotel with difference grade , i want tow show my grid view in this manner :
tour a
hotel a1
100 $
2010 / 5 / 5
hotel a2
200 $
View 2 Replies
Feb 12, 2010
I have a gridview where I placed several item templates with text boxes in them. I want to enter a number in the text boxes and have the total displayed in the footer.
The last footer template is where I want to display the total. I've placed a label there.
Here's my Gridview
[Code]....
View 4 Replies
Nov 30, 2010
I have a Gridview with one column (news title).
i wan to when user click this cells go to another page to show full news.(i know how to use querystring
)
THEN:
How can i change this cells(i think DATABOUND) to hyperlink
View 3 Replies
Nov 10, 2010
Can one use the findcontrol to access the row.cells value? (C#)
[code]
[Code]....
[/code]
I though that this would work, but alas no.
View 2 Replies
Mar 18, 2010
I'm working on a project in vb.net framework 2.0 and have a column that has server names. I have the accessdb sql setup to order by the db, what I would like to do is to have it look like the following picture below. I'm pretty stumped on how to do it as the methods I've found online haven't worked so well. Also just a small tid-bit the gridview is bound to a ddl which selects the application and the gridview refreshes with server data. Country would be server name and state would be the environment.
View 5 Replies
Nov 5, 2010
How to merge gridview columns in a grid when the items in the grid are duplicate. i mean in one row four columns are there i need to merge the columns which are repeating
eg: Mango Mango Mango Apple
i want like: Mango Apple
i the columns mango is getting repeated i need to merge it into one
View 14 Replies
Jan 26, 2010
specially VB code behind pages.I am writing an app with a colleague and I am stuck on something.he app is a holiday booking calendar. I have a gridview that shows the total number of days booked for each month of the year. When you click the cell for say January another gridview is populated below showing each day of january.My problem is that I want to change the formatting of the cells in the second gridview depending upon if any of the cells have a 1 or a 0.
View 3 Replies
May 26, 2010
When retrieving values from Gridview empty cells, you will get " " instead of a empty string or null.
Someone once change the columne's properties as following, but it doesn't work
ConvertEmptyString > true
HtmlEncode > false
HtmlEncodeFormatString >false
One solution is to check if the cell value is " ". If so, assign it an empty string. But this approach looks awkward.
View 9 Replies
Mar 2, 2010
I am able to get the values of GridView cells when the columns are not visible.
For Example:
<asp:BoundField DataField="TemplateKey" Visible="false"/>
foreach (GridViewRow gvrow in GridView1.Rows)
{
gvrow.Cells[0].Text.ToString()
}
But if I make the BiundFiled Visible="true" then I get the value in the code behind.
I do not want to show this value to the user and also want to get the value in the code behind. How can I do that?
View 2 Replies
Mar 8, 2011
we're creating a GridView to display news articles programmatically (not using a SQL database).
We can create & display the GridView, but are having a devil of the time to get the hyperlinks in SetupGrid() attached to the titles
of the articles in the GridView. Below is our .aspx code and .vb code of how we create the GridView. Any ideas on what we should do to get the hyperlinks array of strHyperlinks() in SetupGrid() to be applied to the titles in column 1 of the GridView?
[Code]....
View 2 Replies
Aug 31, 2010
I have a GridView in my page :
[Code]....
But always temp string is empty!
What's wrong with it?
View 1 Replies
Apr 9, 2010
I have a gridview that has both a select and an update statement. One of the cells is a date cell, and the other is for numerics only. Is there a way I can do this? At the moment, anything can be keyed into the cells and this results in an error as my update stored procedure expects a date value and a numeric value respectively.
View 2 Replies
Dec 1, 2010
How can change some cells in gridview that have some condition?
For example:
IF name=="x" column[2].background="red"
(only column for this name)
EXPLAINE :
my GRidview show houses,and i want to when it is for sale the clolum (sell price) background will be another color,and also for rent.
ask 2: I should use the code in RoewCreated event or OnRowDataBound ?
View 2 Replies
May 7, 2015
While uploading excelsheet to datatable and bind it to gridview it will check blank data in excel sheet and when it will bind to gridview,the row in which blank present that row will be in red background color and the other row will occur in normal back color.
View 1 Replies
Dec 13, 2013
I need to change the cell postions of the gridview via drag and drop.
View 1 Replies
Apr 5, 2014
in my gridview there are 4 columns,one of them is Slno.
I want a jquery to move the 3 column parameters up and down except "SLNO"
View 1 Replies