|
Currently, I have something like this:
<asp:DataGrid>
<asp:TemplateColumn>
<ItemTemplate>
</ItemTemplate>
<EditItemTemplate>
</EditItemTemplate>
</asp:TemplateColumn>
</asp:DataGrid>
I was wondering if there was a way (either behind the scenes in C#) or in the markup itself, to make it so that we don't have to duplicate the markup. There was a thread I found for the FormView control, where we could set FormView.EditItemTemplate = FormView.ItemTemplate, but unfortunately, this is not available for the DataGrid TemplateColumn type.
|
|
|
|
|
Greetings,
I think the thread you read already gave you the correct way ... its only a matter of casting the template column correctly then set the EditItemTemplate property to ItemTemplate property ... here is the code:
TemplateField colmun = this.GridView1.Columns[0] as TemplateField;
colmun.EditItemTemplate = colmun.ItemTemplate;
Sincerely Samer Abu Rabie
Note: Please remember to rate this post to help others whom reading it.
|
|
|
|
|
Ah, I didn't think of that. Thanks.
|
|
|
|
|
Hi i am trying to upload a file to a folder in FTP...
i am using asp.net file upload control .. how can i do this ?
Santhapur
|
|
|
|
|
Search google for: upload files +ASP.NET
foreach(Minute m in MyLife)
myExperience++;
|
|
|
|
|
Thanks for your answer..
i have done it prior to posting..
i founded two links donno which one works ?
http://www.codeguru.com/csharp/csharp/cs_internet/desktopapplications/article.php/c13163__2/
http://www.developerfusion.com/code/4340/ftp-client-library-for-c/
Santhapur
|
|
|
|
|
I can understand that you just want to brows for files and upload the file you select to the server
If this is the situation
All you need is the upload control as you did
Then create a file on the sever and copy the data as stream of bytes from client's file to server's file
foreach(Minute m in MyLife)
myExperience++;
|
|
|
|
|
Hi,
I created a webcontrol (Textbox derivated) and I have a property that was suppose to link a Label control to it - when my control gets the focus, I'm gonna change some style from the assigned label.
Here is my code... When I select the Label, my text box disappears and show an error "Error Rendering Control ... Cannot create an object from its string representation"... How can I fix it?
public virtual Label Label
{
get
{
object label = ViewState["Label"];
if (label == null)
return null;
return (Label)Page.FindControl((string)label);
}
set
{
ViewState["Label"] = value.UniqueID;
}
}
Thanks,
Dirso
|
|
|
|
|
It would be nice when someone marks my question as a "Bad Question" tell me why. It might be the solution to my problem and I would vote for him as a big 5.
Thanks,
Dirso
|
|
|
|
|
Why are you storing the label in ViewState ? Why not just create a label and refer to it by name ?
Your core issue imo is that your code requires postback. If you want to change a page when a control gets focus, you definately want to do it on the client, in javascript.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
I'm kinda n00bie on server controls development (big surprise hum )
I created a script (using javascript) that would do the trick of changing colors and styles.
I use this, because I'm creating several forms and in each form there are several textboxes (my textboxes) and so, everytime a textbox gets the focus, the assigned label should have it's style changed too.
Back to the problem, at design time, i want to select in the property window (of each textbox) the label it should change the style from.
I read about TypeConverters, but still not sure how to use it... I'm learning about it now..
Thanks,
Dirso
|
|
|
|
|
I'm not sure about type converters. you'd need to use the ClientID property of the label to get the client side label for your JS to use, I'd just have a property which takes the label in question and gets it's id, and then investigate making this available in the designer.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Windows Workflow foundation(WWF):
I am new to .net 2008 and i am a fresher. I have just learned some bits of practicle programming but know i want to know basics and use of WWF in .net 2008.
since i am working on simple webforms and database which is of basic level so i want to know why we use WWF and how we use this.
even on net i have found most of the learning examples in console application ,which is not comfortable for me .
Please give me some links for some WWF learning videos or learning materials for beginners.
please guide me as a teacher to fresher.
Thanks.
|
|
|
|
|
This particular forum is for ASP.NET specific questions. WPF / WCF / WF forum[^] would be the more appropriate place.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Is it possible to render a page that makes use of a masterpage to Word? I get errors involving controls need to be placed inside a form tag with runat="server". The master page has this form id="form1" runat="server" but when the page runs the ID is aspnetform. However, what I need to do is to render the page's "content" and not the entire viewable page.
Thanks!
Revolutionary: Disk drives go round and round.
modified on Monday, December 1, 2008 1:14 PM
|
|
|
|
|
Hello,
I would like to create a cookie upon login that can be read on two different subdomains. I have achieved this. The problem that I am having is that I am unable to delete the cookie upon logout, as it can still be read even after it is deleted. Here is the code:
At login the cookie is set from a.mydomain.com:
c#
HttpCookie cookie = new HttpCookie("my_cookie");
cookie.Value = "test";
cookie.Domain = ".mydomain.com";
Response.Cookies.Add(cookie);
Cookie reading on subdomain (y.x.mydomain.com) vbscript
myVal = Request.Cookies("my_cookie")
Happens back at a.mydomain.com
Logout:
Request.Cookies["my_cookie"].Domain = ".mydomain.com";
Request.Cookies["my_cookie"].Expires = DateTime.MinValue;
However when I go back to y.x.mydomain.com, the cookie value still show up as what it was initially set to.
Can anyone shed some light onto why I can't seem to be able to delete the cookie.
|
|
|
|
|
I am trying to bind a nested gridview in a loop.
But what happens is I get only the last record on the grid. Rest all previous records get disappear.
for example:
for 1 = 1 to 10
ResultsDataGrid.DataSource = Results;
ResultsDataGrid.DataBind();
In this case I only see the 10 th record. Please suggest or guide
Regards,
Pavas
|
|
|
|
|
Why use a loop ??!!
Just Bind directly
ResultsDataGrid.DataSource = Results;
ResultsDataGrid.DataBind();
foreach(Minute m in MyLife)
myExperience++;
|
|
|
|
|
Got the solution. I made a relation datatable and then used it.
thanks
Regards,
Pavas
|
|
|
|
|
Hello ,
I need some recommendation on retriving data from DB , before today , I take my data from db using data adapter and put it on a datatable and return it to a grid and bind to that grid. From this day , I tried something different and I put entity classes on my application. I created an arraylist which contains those entities and return that arraylist to the grid and bind it. I read somewhere with this kind of binding will be faster than datatable binding. (I am not quite sure yet with this because I could get all the story wrong )
In long story short : I retrive data from my DB using data adapter then fill a data table and then I fill my entities from that data table then create an arraylist then bind it.
Is there any faster (efficient) way to fill my entities or is it the way everyone does?
thanks for your replies.
Revelation 22:13
|
|
|
|
|
Using Entity Class is faster , for sure ..
But as I think it won't be that flexible because tommorow if you make some modification in the StoredProcedure returning some new columns from your SP,
Then u have to make same Changes in your entity class .........
|
|
|
|
|
One Suggestion : You can use caching for improve the Performance of your web application. As per your desing, For Every Request if client need data, it will goes to DataBase Server and then retreive data from there.
My Suggestion, use caching and store data over there, access data from cache. Which will increare performance dramatically.You can Read This Article [^]
Update the cache on aspecific time dealy.
Hope It will help You !!!
|
|
|
|
|
Tugbay Sahin wrote: I retrive data from my DB using data adapter then fill a data table and then I fill my entities from that data table then create an arraylist then bind it.
This is going to be slower. You are doing one step extra.
DataTable is filled using a data reader instance internally. So when you retrieve 10 records from DB, you will loop 20 times to fill your entity class (10 for filling datatable and 10 for filling class from this datatable).
When you use strongly typed entity classes, you don't need data table at all. You get the result in data reader, loop through it and fill your custom class instances. Don't use ArrayList , use a generic List(T) instead. This should be much faster.
Example (Assuming Customer is your entity class with two properties name and age)
public List<Customer> GetCustomers(){
List<Customer> customers = new List<Customer>();
using(SqlDataReader reader = command.ExecuteReader()){
if(reader.HasRows){
int customerName = reader.GetOrdinal("name");
int customerAge = reader.GetOrdinal("age");
while(reader.Read()){
customers.Add(new Customer(reader.GetInt32(customerAge),
reader.GetString(customerName));
}
}
}
return customers;
} Data table is not type safe. This method will help you to avoid many bugs and your code will look much cleaner.
Hope this helps
|
|
|
|
|
Thank you very much for your answers. I got my answer(s)
other recommendations always welcome from me ^^
Revelation 22:13
|
|
|
|
|
Dear Guy,
you came to a good point
Actually DataSets, DataTable, .. are bad for both performance and memory
And you toke a good step by creating Entity classes
But you still use the datatables .. so, you added an overhead as Navaneeth said
There is a free open source framework that handles this for you
It is CSLA try this http://www.lhotka.net/cslanet/[^]
foreach(Minute m in MyLife)
myExperience++;
|
|
|
|