|
I appreciate your quick response. My problem is that it works when I use a SQLDataSource but doesn't work when using an ObjectDataSource. My question is why does it not work with the objectDS when it does work with the SQLDS? The reason I want to use the ObjectDataSource is so that I can add more functionality to the Object. If I could just get it to work as a dropdown in the Gridview Edit, I would be good to go.
|
|
|
|
|
The difference is the dataset that the sqldatasource returns is very different then the collection of Ienumerable of your object. I have written an article on the gridview that uses the object datasource. So it is not quite the same as what you are trying to do with the downdownlist.
If you are just trying to set the source ofthe dropdown in your gridview that shouldn't be too hard. If you are trying to populate the dropdown I can see how that would be a little harder.
Ben
|
|
|
|
|
Thank-you for your responses. I started thinking through it and realized that I was headed in the wrong direction. I switched to using the SQLDataSource and it's working great. It was a case of trying to make it more complicated than it needed to be.
Thanks for you help.
|
|
|
|
|
Hi.
I'm new to ASP.NET (but not C# or VB.NET).
In a nutshell, I have a class (MyClass ) that exposes multiple public properties, and another collection class that Inherits from Hashtable to give a strongly typed collection of the first class, where 'Add' , 'Remove' and 'Item' are implemented to shadow those from the base (HashTable) class by accepting or returning a MyClass object.
I also have a GridView that has its DataSource set to an ObjectDataSource that returns an instance of the collection. Now, at design time, the grid can see all of the public properties of MyClass but, when run, fails with the error I gave in the Subject of this message.
Now, if I change the code so that instead of returning a HashTable I return an array MyClass() , all is well. The designer can still see all of the properties and the code runs fine.
Does anyone know why this is? If the designer can see the properties at deign time then why not at run time?
I would really rather have my code return the collection instead of the array.
Many thanks for your help.
Kelvin
|
|
|
|
|
In my experience I have used Generic lists for my objectdatasource to return not Hashtable. Something like List<myclass>. Anyway, I have found it to work quite well for me.
Hope that helps.
Ben
|
|
|
|
|
I have a situation where I need your help. I have home.aspx page, which is consuming three frames as Leftmenu, TopMenu and MainContent. As name suggests leftmenu is for lefthand side menus, Topmenu is for company logo etc and maincontent iframe is for all other pages display which are selected by user from LHS menu.
I am displaying User name through session value on TopMenu iframe. This session is coming from default.aspx page.
Now problem start from here…Application provides the flexibility to user to change the user name from inside the application through one menu option. So for this we had provided an interface which gets open in mainContent iframe. On click of Submit button, I reset the value of session but it is not reflecting on TopMenu page as this is on different iframe.
If i do F5 then value get change on topmenu.aspx.
I tried to refresh the same page through JavaScript also but I am having bad luck as of now….Please let me know the best and shortest way to do so...
Amit
|
|
|
|
|
call a js function on clientclick event of submit button, and refresh the top frame page like this
window.parent.frames("topframe").location="topframepage.aspx"
i hope this will work.
many thanks,
adnan
Many Thanks,
Adnan Rafiq
muhammadadnanrafiq@gmail.com
|
|
|
|
|
No it does not help....Any other suggestion
|
|
|
|
|
hi
i am dev a web application in visual web dev express..
wen using the gridview control i wanted that the date column be formated in (dd/MMM/yyyy) format.
i m entering in the gridview EDIT ITEM option
{0:dd/MMM/yyyy}
this aint working.
how can i do this..
Kunal Piyush
|
|
|
|
|
If you are using the Eval method of binding it looks like this:
<%# Eval("Date", "{0 }")%>,
If you are using a boundfield it looks like this:
<asp:boundfield datafield="Dtm" sortexpression="Dtm" headertext="Date" htmlencode="False" dataformatstring="{0 }">
Finally if you use a DataBinderEval (that is what I suggest)
You have this:
<%# DataBinder.Eval(Container.DataItem,"Date").ToString("dd/MMM/yyyy") %>
The other two options you really can't give it the dd/MMM/yyyy format.
Hope that helps.
Ben
|
|
|
|
|
kubben wrote: Finally if you use a DataBinderEval (that is what I suggest)
You have this:
<%# DataBinder.Eval(Container.DataItem,"Date").ToString("dd/MMM/yyyy") %>
hey
i tried wat you said
on the page load event i wrote this
DataBinder.Eval(GridView1.Columns[10], "Date").ToString("dd/MMM/yy");
i couldnt get wat COntainer.dataitem meant.. there wasnt any optio for the same.. i used columns[10], since the date column was the 10th including 0..
but i get an error..
tostring only takes 1 argument..
please help
Kunal Piyush
|
|
|
|
|
In the gridview. You need to convert the column you want the date in to be an ItemTemplate. In the ItemTemplate you need a Label control. In the Text property of the Label control you need to put the this:
<%# DataBinder.Eval(Container.DataItem,"Date").ToString("dd/MMM/yyyy") %>
The page load event is not the correct place to put this code.
So if you look at your gridview in the HTML mode you will find the <Columns> node
YOu need code like this:
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="lbDate" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"Date").ToString("dd/MMM/yyyy") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
NOTE the Date that comes right after the Container.DataItem is what ever your are calling your date field.
Hope that helps.
Ben
|
|
|
|
|
this is wat i did..
<asp:TemplateField HeaderText="Dt" SortExpression="Dt">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Dt") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"Dt").ToString("dd/MMM/yyyy") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
still that error..
Error 1 No overload for method 'ToString' takes '1' arguments C:\Documents and Settings\Kunal\My Documents\Visual Studio 2005\WebSites\diag\User\viewalldoc.aspx 25
Kunal Piyush
|
|
|
|
|
Sorry I missed on thing:
'<%# Convert.ToDateTime(DataBinder.Eval(Container.DataItem,"Dt")).ToString("dd/MMM/yyyy") %>'
That should work.
Thanks,
Ben
|
|
|
|
|
hey
now the program is compiling.. but again 1 problem.
when the grid is displayed the "Dt" column shows the whole HTML tag, instead of the date.
i am using VISUAL WEB DEVELOPER EXPRESS 2005.. is is a problem of obsolete tag.
Kunal Piyush
|
|
|
|
|
I am guessing there is an unbalanced quote or something. Include the code and I will see if I can see anything wrong with it.
Ben
|
|
|
|
|
i am including the code..
though there shud have been an error regardin an unbalanced tag..
but still
<asp:TemplateField HeaderText="Dt" SortExpression="Dt">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Dt") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%Convert.ToDateTime(DataBinder.Eval(Gridview1.DataItem,"Dt")).ToString("dd/MMM/yyyy"))%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
Kunal Piyush
|
|
|
|
|
Your code:
Text='<%Convert.ToDateTime(DataBinder.Eval(Gridview1.DataItem,"Dt")).ToString("dd/MMM/yyyy"))%>'
Needs to be:
Text='<%# Convert.ToDateTime(DataBinder.Eval(Gridview1.DataItem,"Dt")).ToString("dd/MMM/yyyy"))%>'
That should do it.
Ben
|
|
|
|
|
hey ben
thanks a lot.. problem solved.. thanks again..
Kunal Piyush
|
|
|
|
|
Sorry it took so long.
Ben
|
|
|
|
|
hey.. i need to be sorry... didnt take in consideration about the brackets..
also.. why did we use "container" keyword.. we were using a gridview..
Kunal Piyush
|
|
|
|
|
In this case the Container is referring to the Dataset or dataTable or dataview that is bound to the gridview. When you use DataBinder.Eval you always have to use container.dataitem and then pass in the field you are looking for. The Bind method does the same thing it is just behind the scenes.
Ben
|
|
|
|
|
Hi,
I am an application in ASP.net 2.0with c#.
I would like to use FileUpload web control with Atlas In my application. If I remove the atlas property from my application then FileUpload Web Control is working well. But using Atlas property FileUpload is not working.
Is there any way to use FileUpload Web Control along with Atlas in my application?
Any help is appreciated.
Regards
Rajesh
rajesh
|
|
|
|
|
It doesn't work because the form type must be sent as multipart/www-encoded (I forget the exact string but its something with "multipart" in it). The Atlast async request is sent as a normal POST with just form field values. Google it or search on the ASP.NET AJAX forums, you won't be the first with this problem.
|
|
|
|
|