ok i see where your problem is. You assume if you add a checkbox, it will carry the ID of the checked field , that is not true. I normally create an extra template field and bind the label with the value and as you did on the server side, i find the label and get the value. I have compiled an example and this will help you
I create a gridview with runtime columns. after that add textbox in this column.
Here the code.
protected void grdOne_RowDataBound(object sender, GridViewRowEventArgs e)
if (e.Row.RowType == DataControlRowType.DataRow)
TemplateField T = new TemplateField();
GridViewRow gvr = e.Row;
TableCell tcell = new TableCell();
for (Int32 i = 0; i < columnCounter; i++)
TextBox tb = new TextBox();
tb.Width = 30; tb.Text = "0";
tb.ID = "tb_" + i.ToString();
But when i fetch textbox value from this grid that comes with error.
can any one tell me how to fetch textbox value from my grid
m using these line of code to fetch textbox values
public void GetArray(GridView grd)
String[,] ar = new String[rowCounter, columnCounter];
for (int i = 0; i < grd.Rows.Count; i++)
for( int j=1; j<= grd.Columns.Count; j++)
String tId = "grdOne_ctl03_tb_" + j.ToString(); String t = ((DataControlFieldCell)(grd.Rows[i].FindControl()).text;
Something issue with control Id, it's not able to find the exact control id. It may be issue with control hierarchy. I have some suggestion for you:
1. If you want to follow the same code then view the page source and see what is name of control id and under which parent control has created.
2. Other way, Create a template column at design time and put there a panel. On runtime find the panel and add the all textbox control inside the panel.
same way, during retrieval find the Panel and traverse the all child control.
I use ASP.NET web site
Type: Visual Basic
.Net Frame work 4
When we give the path of other page ,without Login page Like http://localhost:1413/Main.aspx,It must go to Login page
(web application RUN time)
You can do this yourself. Keep a session flag in your application. Set it to true/logged-in, once someone logins. Orelse keep it as false/not-logged-in. On any other page load, check the value of this session and move accordingly. If you find its value as false then do a hard Response.Redirect yourself in the code to login page.
Now to extend this , you will need a Session variable that will carry the username of the Successful login and every page you must check if the Session is null , if its null redirect the user to the Login Page like this
I want to encapsulate the Data Access Layer in a class library project where the class library will contain LINQ to SQL classes and Business Logic Layer. For my ASP.NET Web application, I will add that class library reference so that the ASP.NET Web application just behave like the Presentation Layer. I am highly tempted to implement this architecture. But I just got one challenge. As the Data Access Layer will maintain the Connection String of the SQL database in Web.Config file, when I reference that class library DLL to my ASP.NET Web Application, how will the Web.Config file of that class library project get integrated to my web.config file of the presentation ASP.NET Web Application ?
At this moment, I am using ASP.NET 4.0 which has a cool feature : Web.Config.Debug, Web.Config.Release, so I can place the connection string of my production server website at Web.Config.Release. But, now, looks like, I will have to miss that feature as I am not sure how Web.Config (or App.Config) file will behave in my Data Access Layer class library project.
Thanks for your reply. I understood how to read connection string from my DAL. But, the DAL class library will be compiled to a single DLL file which can be added as a reference to my Presentation Web Application, how can I import that config file to my Presentation Web Application where the Presentation Web Application already contains Web.Config file. Wont that conflict ? Moreover, when the DAL assembly is added to the Presentation layer Web App, will my DAL DLL know that what is the config file it must read from ?
Any assemblies used in your application will use the configuration file from the main executable, unless otherwise specified. Copy the settings necessary for your data access layer to the web.config file.