VS 2008 Bound Gridview Control - Check When No Data?

Dec 16, 2010

I have a gridview control on a .aspx page. It is a bound control. So basically I didn't have to write any code to pull the data from database and show it on the grid.

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionStrdatabase %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
SelectCommand="SELECT * FROM order WHERE SETTLEMENT_DT > AS_OF_DT"
</asp:SqlDataSource>
<asp:GridView ID="GridViewMissingCusipNumbers" runat="server"
AllowPaging="True" AllowSorting="True" SkinID="Professional" Font-Name="Verdana"
Font-Size="10pt" Cellpadding="4"
HeaderStyle-BackColor="#444444"
HeaderStyle-ForeColor="White"
AutoGenerateColumns="False"
DataSourceID="SqlDataSource1" DataKeyNames="BO_SECID"
onrowcommand="GridViewMissingCusipNumbers_RowCommand" Height="285px"
onrowediting="GridViewMissingCusipNumbers_RowEditing"
onrowupdated="GridViewMissingCusipNumbers_RowUpdated"
onrowupdating="GridViewMissingCusipNumbers_RowUpdating" Width="426px"
onrowcancelingedit="GridViewMissingCusipNumbers_RowCancelingEdit">
<Columns>
<asp:BoundField ReadOnly="true" DataField="BO_SECID" HeaderText="BO SECID"
SortExpression="BO_SECID" />
<asp:BoundField DataField="CUSIP" HeaderText="PROXY CUSIP" SortExpression="CUSIP" />
<asp:BoundField DataField="PRICE" HeaderText="PRICE" SortExpression="PRICE" />
<asp:CommandField ShowEditButton="true" />
</Columns>
<HeaderStyle BackColor="#444444" ForeColor="White"></HeaderStyle>
<AlternatingRowStyle BackColor="Silver" BorderColor="Black" />
</asp:GridView>

So far so good. But where is no data is not returned from the database, I want to display something on the page saying "No data returned". But I don't know which gridview control event gets fired so that I can write some code in it to check if the records returned are zero.

View 1 Replies


Similar Messages:

VS 2008 / Gridview Control - Update Error - ORA-01008 - Not All Variables Bound

Jul 29, 2011

I have a simple gridview control. It has edit and cancel buttons for each row. User's can click on edit column and edit a row and click on save to save the record.

When the user clicks on save we get the error: ORA-01008: not all variables bound

User is allowed to edit only 3 fields and rest of the fields are only readonly. For those editable three fields, I am using EditItemTemplate. ASP.net doesn't throw any errors for the first two edititemtemplates. The problem comes only with the third field which is "BSIS Type". I tried to figure out almost 5 hours and don't know what to do.

This the code I have:

HTML Code:
<asp:GridView ID="GridViewActualsMapping" runat="server"
HeaderStyle-BackColor="#444444"
HeaderStyle-ForeColor="White"
Font-Size="10pt" Cellpadding="4"
AutoGenerateColumns="False"

[code]....

Error is:

HTML Code:

ORA-01008: not all variables bound

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.OracleClient.OracleException: ORA-01008: not all variables bound

View 5 Replies

VS 2008 - GridView Bound Column And Bind Data

Jul 11, 2011

I am trying to create a bound column and bind the data with the below piece of code . And the column has two files Name and Fee but the code binds only the Fees column and Name column become empty..

Code:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

[Code] ....

Design Part

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">

[Code] ....

View 7 Replies

VS 2008 DetailsView And GridView Bound To A DataTable

Mar 2, 2011

I'm hacking my way through ASP.Net WebForms, coming from VB.Net WinForms. I was hoping the transition would've been more seamless... it is not.

I have a GridView (Paging enabled) bound to a DataTable, filled with Joined tables from an Access 2000 DataBase.

The GridView and DetailsView are bound to the same DataTable.

In the GridView's SelectedIndexChanged Event I have the following:

vb.net Code:

' dtvSelected is the DetailsView' dgvJobTOF is the GridView Me.dtvSelected.PageIndex = Me.dgvJobTOF.SelectedIndex

When the page loads the first item in the GridView is also displayed in the DetailsView.

I've added a "Select" button in the GridView and when it is clicked the Data in the DetailsView remains the same regardless of the selected GridView row.

DataBinding Method:

vb.net Code:

[code]....

View 14 Replies

Forms Data Controls :: Giving The Panel Control A Dynamically Bound Value (3 Way Nested Gridview)?

Jan 5, 2010

I have a 3 level deep nested gridview. The expansion/contraction of each record was originally done with javascript. There were html <div> tags around each gridview. Since these were HTML div tags I could give them IDs that were dynamically bound to record ID value within the database. I then had onclick buttons that passed in a bound record ID value that coresponded to the appropriate div tag that needed to be expanded (e.g. display: inline (show it) or if it is already inline then display: none).

This worked beautifuly. Unfortunatley I wanted to be able to do in-girdview editing of the child records. When expands a parent record and clicks to edit a child record the OnRowEdit event fires which automatically generates a postback and resets the variables within the JavaScript. THEREFORE THE ENTIRE GRIDVIEW STATE BECOMES CONTRACTED.

So finally I decided to change the div tags to <asp: Panel> and the onclick images to .net clickable images (all .net objects no framework). This works because the state is remembered within each postback. However, the problem I'm having is I can't dynamically bind ID's for panel since this is not allowed. HOW CAN I GIVE THE PANEL <% Bind("id") %>. THAT I CAN REFER TO SO I CAN OPEN THE APPROPRIATE PANEL.

View 1 Replies

VS 2008 / Show The Data Either In Chart Control Or Gridview Control?

Feb 11, 2013

I have a simple .aspx page.

I want to show the data either in Chart control or Gridview control. When the user selects an option to see the data either in chart control or grid view control, that specific control has to show up and other control has to become invisible.

So far, I am able to populate data successfully in the chart control. If the user chooses "Grid view" option, how can I show the data in grid view control in the same location. I don't want the gridview control to be shown in a pop up window or any other window.

View 2 Replies

Forms Data Controls :: Check Box Control Inside The Gridview

May 20, 2010

I wrote simple program in that i have one gridview in that i added one template field Checkbox controll.

this is my gridview1

<asp:GridView ID="GridView1" runat="server" Width="100%" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" AllowPaging="True" OnPageIndexChanging="GridView1_PageIndexChanging"
PageSize="20">
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:TemplateField >
<ItemTemplate>
<asp:CheckBox runat="server" Text='<%# DataBinder.Eval( Container.DataItem, "Title") %>' ID="chk1" />
</ItemTemplate>
</asp:TemplateField>
<%-- <asp:BoundField DataField="Title" HeaderText="Title" />--%>
<asp:BoundField DataField="Creation_Date" HeaderText="Creation Date" />
</Columns>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>

i have one button control in that click event i write some code like this

protected void btndelete_Click(object sender, EventArgs e)
{
CheckBox chk;
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox cb = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("chk1");
if (cb.Checked)
{
Response.Write("checked");
}
}
}

but when i run this code that check box return vlues every time false when i clicked the checkbox.

View 3 Replies

VS 2008 / Transposing Data In A Gridview Control?

Jul 1, 2011

The data in my dataset looks like the following:

Here is how the data looks in the dataset :

Deal Cashflow Date
-----------------------------------------------
0007 1228888 01/12/2011
0007 898998 02/12/2011
0007 999999 03/12/2011
0008 888888 01/12/2011
0008 777777 02/12/2011

When I transpose the data, it should look like this:

Deal 01/12/2011 02/12/2011 03/12/2011
0007 1228888 898998 999999
0008 888888 777777

View 4 Replies

Forms Data Controls :: Check Visible True Of Control In Gridview RowEditing Event?

Feb 2, 2010

i am developing an application using ASP.NET with C#.net. in my application i have a gridview contains 3 fields.

1.description

2.unitprice

3.Regions

these three are template fields and last field i.e Regions is set to visible false.

code is

[Code]....

when the grid is binded,i am not displaying the regions field as that is set to visible false.

when i click the edit button i.e in RowEditing event of grid i have to show the Region field.

for that i had wrriten the code as

gvoptProgramdetails.Columns[2].Visible = true;

when i run the application and when i click a perticular row of edit The region field is set to visible to all rows which are there in gridview.

my requirement is i have to show the region of perticular row in gridview which i have selected.

View 2 Replies

Forms Data Controls :: Uncheck And Check The Check Box Inside Gridview Using Button?

Nov 12, 2010

i have a UP and DOWN buttons ouside a gridview and a checkbox inside the templated field .I will check the checkbox to sleect a row , after that if i click on UP button the checkbox above the selected checkbox should be selected.

same with when i click on DOWN button the checkbox below the selected checkbox should be selected.

View 2 Replies

Forms Data Controls :: Uncheck / Check A Check Box Inside The Gridview

Jan 6, 2010

I have a grid view with two columns...one column has a no. like (123) and a check box....which user can checked or unchecked......all I need to do is that I need to disable the man handling of that check box......rather I would like to see a seperate grid view with the same no. of rows as of the first and in this gridview I may allow to type in or scan the no. and if this scanned or typed number matches any no. in the first gridview number then the corresponding check box should be checked/unchecked.

View 1 Replies

Forms Data Controls :: Display A One Row Gridview When Gridview Is Bound To Empty Dataset

Jan 13, 2010

If the gridview binds to empty dataset, I need to still show a gridview so that users can ADD more using the textfields in the bottom of the footer template. Since the gridview is empty it won't bind not allowing rendering of the <footer template> I guess I should create a empty dataset if the gridview is empty. How do I check for this and can this be done in GridviewRowEventArgs

View 5 Replies

VS 2008 How To Check If Data Set Is Empty

Feb 22, 2011

How can i check if dataset is emty some thing like follows

if dataset=emty then
msgbox("NO table")
else
....
End if
I am importing excel files from root folder, when file not there then message should apeear to avoid collapsing application.

Code:
ry
Dim strExcelConn As String = System.Configuration.ConfigurationManager.ConnectionStrings.Item("ExcelConnection1").ToString()
Dim dbConn As New OleDbConnection(strExcelConn)
Dim strSQL As String

[code]...

View 9 Replies

How To Keep Bound Data And Add New Row To Gridview

Apr 19, 2010

this is my my code snip

[code]....

I put a textbox and a button to page when user click Button , I want to insert a new row to datagrid assume

TextBox.Text = Vivi

when user click Button

first : I use TextBox.Text to DataBase retrieve data for this No (ex: select Name, Tel from student where No = '" TextBox.Text + "'")

and then I want to add this datarow to my DataGrid

I hope I can get result like this

[code]....

How to open a new row to existing GridView? and still keep original data?

View 2 Replies

Web Forms :: How To Get Data Bound Server Control

Mar 23, 2010

i am new to asp.net and need some help with writing a user control that fits the following specification:

i have a list of properties. each property is a string triplet (type, name, value). TYPE can be "boolean", "string", "int" with VALUE taking appropriate values.

so a list of properties would look like: {("boolean", "isMember", "true"), ("int", "age", "39")} .

i need to display the list of properties in a table with a corresponding control for each value type

("boolean" in a CheckBox, "string" "int" in a TextBox)

and be able to to edit the values. I wrote a small control that displays a single property. It puts the NAME in a Label and depending on the TYPE inserts

the value in a TextBox or CheckBox and then puts that in a PlaceHolder. I could afterwards display the list in a table when a button is clicked.

View 2 Replies

Best Way To Create A Data Bound User Control?

May 25, 2010

What is the best way to create a data bound ASP.NET user control? I have a user control that contains a drop down list and three label controls. I would like to data bind the drop down list, and have the label controls display different properties of the data source. I have Googled for an example of IDataSource and User Control, but cannot find any good information. This must be a common use of a user control?

View 1 Replies

C# - Implement A Data-bound Control With Templates?

Jan 25, 2010

I want to implement a very simple list control. It has 2 properties:

RowTemplate (ITemplate)
DataSource (IList)

The control implementation must render each row using the template specified in RowTemplate passing the corresponding object in the DataSource list, so that, if I have a property called Name in the passed object, it would be accessible with a Eval("Name").

I want an example of how to render the control using RowTemplate and how to pass the correspondent DataSource object to the template.

I'm reading the MSDN documentation on the subject: Data Binding Expression Overview and Binding to Databases but I just can't find how to implement a control that passes an object to the template.

View 1 Replies

Forms Data Controls :: Can Visual Studio 2008 Gridview Control Do Grouping

Mar 1, 2010

Can Visual Studio 2008 Gridview control do grouping? And how?

View 1 Replies

Dynamically Assigning Properties On A Non Data Bound .NET Control?

Mar 18, 2010

For example, let's say I have a HyperLink:

<asp:HyperLink runat="server" Text="Foo" NavigateUrl="foo.aspx" />

How can I set the NavigateUrl on the server side, without having to go the code-behind?

This doesn't work of course:

<asp:HyperLink runat="server" Text="Foo" NavigateUrl="<%= urlString %>" />

(where urlString might be a string I created earlier in the page)And this doesn't work because the HyperLink is not within a data bound control:

<asp:HyperLink runat="server" Text="Foo" NavigateUrl='<%# urlString %>' />

I guess I could just use a standard anchor element:

<a href="<%= urlString %>">Foo</a>

But I'd rather not mix up HTML and ASP.NET controls, and it would be handy to be able to do this for other controls.

View 2 Replies

Forms Data Controls :: Using Event For Data Bound Control Vs Data Source?

Jan 1, 2011

I've been using the Item Inserted event for my data controls, such as details view. I'm wondering if there are advantages to doing this with the data sources instead of the data control. There is a lot of overlap in the events provided by these two types of controls. Are there advantages to using the events raised by the data source instead of the ones raised by the data control itself. Should I be using the events raised by the data source instead of the control used to enter the data?

View 2 Replies

Forms Data Controls :: Reset Data Bound User Control Shown With Ajax Pop - Up Extender

Nov 1, 2010

I have a web form, and an "add vendor" button. Click the button, a modal dialog pops up (ajax:ModalPopupExtender). User selects one of two radio buttons which shows a data bound asp:View in an update panel - this view is data bound to a single row and must be populated by the user. However I also want to provide a cancel button which should close the modal dialog and reset the bound view.

However what is happening is that the ModalExtender closes, but when the "add vendor" button is presented again, it's still bound to the same data. Do I need to clear my data source? How so I reset the forms/views so that when the 'add vendor' button is clicked again the form is presented as it should be (IE the 2 select options, picking one re-binds the asp:View)?

View 1 Replies

Forms Data Controls :: Get PropertyName Of Data Bound Control?

Mar 26, 2010

is there a way to get the PropertyName of a data bound control? For example:

I have a text box like this:

[Code]....

How can I get the info that this text box is bound to the property with the name "Test"?

View 8 Replies

GridView Style Based On Bound Data?

Apr 30, 2010

I would like the rows of my GridView to have strikethrough based on a bound data value called IsObsolete. I tried to do this:

<RowStyle BackColor="#EFF3FB" Font-Strikeout='<%# Bind('IsObsolete') %>' />

But obviously this doesn't parse. I'd rather not do this in GridView.DataBound().

View 2 Replies

Forms Data Controls :: How To Get The Row Value Of Gridview Upon Bound

Jul 2, 2010

I got his code for RowDataBound

[Code]....

View 4 Replies

Forms Data Controls :: ListView Control That Is Bound To An SQLDataSource?

Jul 5, 2010

I have a ListView control that is bound to an SQLDataSource.

View 6 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved