Forms Data Controls :: Setting EmptyDataText From Code Behind
Jun 10, 2010
I would like to be able to set the EmptyDataText property using code-behind. I have created a custom GridView control called PagingGridView. Here is the definition:
public class PagingGridView : GridView {
}
In my ASPX page, I would created a new GridView definition by doing this:
<cc:PagingGridView id="MyGrid" runat="server" ><cc:/PagingGridView>
When I databind the control, I would like my custom control to automatically detect an empty data source and build a table with all the header columns and a row containing the empty data text. The rendered code for the empty data source would be like:
<table>
<tr>
<td>Col1</td><td>Col2</td>
</tr>
<tr>
<td colspan="2">No Records to display</td>
</tr>
</table>
My initial thought was to override the EmptyDataText property but I could not get that to work.
View 3 Replies
Similar Messages:
Dec 19, 2010
i want to show my style(for example font color) when gridview is empty.i want to make style for emptydatatext. is it possible?
View 5 Replies
Apr 28, 2010
Does somebody have a clue about my following issue? I have a gridview with it's datasourceid set to "ods". I have two objectdatasources. One is called "ods" which contains a list with all contracts. The second objectdatasource is called "odsAuthorized" which contains a list with all authorized contracts.
Now i have two linkbuttons "Show All " | "Show Authorized" whith an onClick event where i set the datasourceid of the grid.
When i click the "show authorized" i see a list of all contracts which are authorized. Now when i click on "Show all" is see a list with all contracts. So the onClick events work fine, however. When i change the status in the database so i have 0 authorized contracts, and click on the "Show Authorized" i get to see a label which says "Sorry no records have been found" because i have set the EmptyDataText property on the gridview. Now when i click on Show All, the onclick event for the Show All button never gets fired. I do see that a postback occurres. But i don't come into the event. Does anybody have a logica for this?
View 7 Replies
Jul 10, 2010
I am working on a site using .aspx controls. Currently I am working on a search feature which searches my database of records and produces all applicable results to the search. Everything works as planned. I have recently added the EmptyDataText line to produce a specific output anytime no results are found in the database. However, I would like to be able to alter/change the appearance of the EmptyDataText output and cannot figure out how to do so. For example, if no results are returned from the search, I would like the EmptyDataText to produce an output of something along the lines of "Your search has produced zero results.
double check your spelling and try your search again." I would like to change the font color, font size, and possibly the thin box which is automatically produced around this output. Is any of this possible? If not, is there another way to produce the desired results? Ultimately, I would actually like to have the results actually use the terms which were input to the search within the EmptyDataText results when no search results are found within my database. For example, if "widget" was used as a search term and "widget" was not found within my database then i would like the results page to state something along the lines of: "Your search for 'widgets' did not return any results. check the spelling and try your search again." Does anyone know how to do any of these things using ASP.Net?
View 1 Replies
Jun 9, 2010
I can't seem to get either EmptyDataTemplate or EmptyDataText of a GridView to work. I'm fetching the GridView contents in de codebehind and attaching them with using DataBind(). I've tried having them as null and as an empty List, and in both cases the text I put intoEmptyDataTemplate or EmptyDataText is not displayed. What am I doing wrong?
EDIT (Code snippet) This is my GridView:
<asp:GridView ID="grid" runat="server" EmptyDataText="EMPTY"></asp:GridView>
And I've tried these two for binding the data:
grid.DataSource = new List<object>();grid.DataBind();grid.DataSource = null;grid.DataBind();
View 5 Replies
Nov 3, 2010
I've got a dropdownlist and a Gridview Based on the choice from the dropdownlist (which has a '--Select--' as the first item), the gridview is populated. If nothing is in the database when queried, I have a message for the emptydatatext property of the gridview. However, it comes up when the page first loads, since it's based on the ddl. How can I make it so that, when the page loads for the first time, the emptydatatext property is ignored?
View 3 Replies
Mar 26, 2010
I have a DropDownList when selected, brings up Detail Info in GridView1. That GridView has a LinkButton when selected brings up the final Detail Info, in GridView2. need to have the GridView2 clear out and display as when it is "EmptyDataText", when the DropDownList is changed.
View 5 Replies
May 5, 2010
using asp.net/vb.net 2005
In the aspx page I have the EmptyDataText property set
[Code]....
However when no records are not returned I am not seeing the text "No Results Returned" I am populating the gridview using a SqlDataSource. I am not sure why this is happening but thinking about setting the value programmatically, does this make sense and if yes which gridview event should I do this? has anyone else experienced something like this before?
View 19 Replies
Jul 12, 2010
[Code]....
But i can not see "no result found". Why? I am using .net 3.5! The same with emptydatatext...
View 15 Replies
Feb 11, 2010
I would like to set a value:
[code]....
...where [HERE] is the placeholder for my value, from my code behind in ASP.NET before the page is rendered. I generate a guid, and I need that apart of the script on the page.
View 2 Replies
Jun 15, 2010
I'm trying to dynamically create a grid view in C#, the grid will have two columns, one of which is a hyperlink field.Now i've noticed when creating the grid view statically in aspx, the DataNavigateUrlFields property accepts a single string as it's value (the field in the data source with the URL in).
When creating it in code, the very same property is a string[] array, rather than a single string, and is expecting multiple fields which combine together to make the URL (if I've understood MSDN correctly), but what if I just want a single field for the URL?
Why does aspx let me do this, but the C# not?
Here's my code:
Name.HeaderText = "Exercise"; Name.DataField = "Name"; Link.HeaderText = "More Info"; Link.DataTextField = "Link"; Link.DataNavigateUrlFields = "Link";
The code above does NOT compile, I got the following error:
Error 2 Cannot implicitly convert type 'string' to 'string[]' This is regarding the last line.
Here is the aspx code, which it's fine with:
<asp:HyperLinkField HeaderText="More Info" DataTextField="Link" DataNavigateUrlFields="Link" target="_blank" />
Does anyone know how I can dynamically create a hypertext field for a grid view, where it only takes a signle field from the data source as the URL?
View 3 Replies
Mar 3, 2011
I am trying to set up my first custom validator in VS 2010 VB. I want it to use a Sub or Function that is in my code-behind. I have searched the WEB but the instructions and examples that I have found do not show me how to use code-behind.
The main problem that I am running into is that I can not find a way to connect the validator to a sub that preforms the validation check.
View 3 Replies
Nov 10, 2010
I have a master page (Site.master) with a navigation menu linked to a datasource (Master.sitemap). I have a nested master page that has another navigation menu. For any item clicked in this nested navigation menu, I want a particular menu item in the Site.master navigation menu to be selected.
Here's my Site.master menu:
[Code]....
In my Site.master.cs I have this:
[Code]....
In the nested master page, Products.master I have this:
[Code]....
In the Products.master.cs file I try to change the selected item.
[Code]....
The master navigation and products navigation menus work just fine by themselves. But when I've tried to set the selected item of the master menu in the Page_Load above, I can't seem to access it. What I've found in trying to do this is the NavigationMenu seems to be uninitialized. The menu Items list is empty. What am I missing here? Why are there no menuItems in the Master.NavigationMenu control?
View 2 Replies
Feb 5, 2010
How can I call onblur event or calculate javascript function in the textbox when I setting values in the textbox in code behind??
<asp:TextBox id="txtQuantity" onblur="calculate(this.id);" Columns="6" Rows="1" TextMode="SingleLine" MaxLength="10" CssClass="xTextBox" runat="server"/>
View 2 Replies
Apr 19, 2010
I'm using user controls as web parts in an asp.net application. I have skinned the webparts by adding .PartTitleStyle (etc) to my css. I'd now like to let the user select from a list in an editor part to choose the style for the web part.I'm able to change the title for the webpart, but can't seem to figure out how to change the css to use .PartTitleStyleCustom instead of the default, even trying to set the wp.BackColor seems to have no effect. Here is the code I have so far in the page load event of my user control:
[Code]....
[Code]....
View 1 Replies
Jun 3, 2010
I can't seem to get either EmptyDataTemplate or EmptyDataText of a GridView to work. I'm fetching the GridView contents in de codebehind and attaching them with using DataBind(). I've tried having them as null and as an empty List, and in both cases the text I put into EmptyDataTemplate or EmptyDataText is not displayed. What am I doing wrong?
EDIT (Code snippet) This is my GridView:
<asp:GridView ID="grid" runat="server" EmptyDataText="EMPTY">
</asp:GridView>
And I've tried these two for binding the data:
grid.DataSource = new List<object>();
grid.DataBind();
grid.DataSource = null;
grid.DataBind();
View 2 Replies
Dec 23, 2010
I try to set the selection in the radiobuttonlist accordingly to data retrieved from the database.
This is not working (the mydata.gender contains "Mail")
mygender = myfatality.gender
View 2 Replies
Mar 8, 2010
I have a gridview on a page but when the results are rendered they push the page out to the right causing you to have to scroll left to right.
Is there any way I can set max width on this?
Here is my code:
[code]....
View 3 Replies
Oct 4, 2010
I have a database which holds the path of an image. It also holds the recomended height and width of the image. My question is how can I set the height and width properties from my database? I have tried the following with no avail:
[Code]....
View 6 Replies
Feb 26, 2010
I have a gridview with a bound column,a template field with an editable textbox and a template field with a readonly textbox.
The bound field value is coming from database. I will enter a value to the editable textbox field. I want to set a value to the third cell based on the entered value in second cell . If the second cell is lost focus i want to set the value to third cell . If the solution is with a javascript function i will be very happy.
View 4 Replies
Jun 17, 2010
I have a GridView with one checkbox and some fields. Now what I want is to set this checkbox dynamically on the execution of a particular function.
ie..i have a mailsend function in my code.. when this function executes the checkbox in my gridview should be set dynamically.. How do I go about acheiving this?
My codebehind is in VB.
View 12 Replies
Feb 11, 2010
Working on a web part that will contain a datalist. How do you set up various properties such as ItemStyle, AlternatingItemStyles, and all the data binding?
I've search for some keywords but could not find anything relevant.
View 7 Replies
Mar 31, 2010
Based on some dates and certain criteria in a database, I need to be able to alert my end users by setting a cell or a row if that is easier to blink. Does anyone know how to do that? I am using Gridviews and dynamic built gridviews and I am using VB.
View 2 Replies
Jul 1, 2010
I have a number of radio buttons on my page. When one is selected, I wish for certain controls to be made visible/invisible.
Can anyone tell me the property to code in VB behind code?
View 5 Replies
Mar 11, 2011
I'm populating a dropdownlist in a formview with a different datasource from the formview's. I need to set the selected value according to the value in the formview's datasource but I'm having a hard time doing that.
Here's the code:
<asp:FormView ID="FormView1" runat="server" DataKeyNames="ID"
DataSourceID="SqlDataSource1">
<EditItemTemplate> [code]....
View 2 Replies