473,397 Members | 2,084 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Datagrid fails to show data!

Hi,
I have a datagrid that is ment to insert data. But when I run the form
only the header appears. I would like some advise from you all and
solve this problem I'm using visual studio 2003. My code looks like
this:

private void Fill()
{
DataTable table = new DataTable();
SqlDataAdapter adapter = new SqlDataAdapter("SELECT * from
dbo.DashBoard", con);
adapter.Fill(table);
}
private void Bind()
{
DataTable table = new DataTable();
dgis.DataSource = table;
dgis.DataBind();
}
private void InsertEmpty()
{
DataTable table = new DataTable();
table.Rows.InsertAt(table.NewRow(), 0);
}

private void bttnew_Click(object sender, System.EventArgs e)
{
// inserting
dgis.EditItemIndex = 0;

// modify text
EditCommandColumn ecc = (EditCommandColumn) dgis.Columns[5];
ecc.UpdateText = "Insert";
EditCommandColumn ecc1 =(EditCommandColumn) dgis.Columns[4];
ecc.UpdateText = "Insert";

// fill table, insert empty row, bind to datagrid
Fill();
InsertEmpty();
Bind();
}
private void dgis_ItemCommand(object
source,System.Web.UI.WebControls.DataGridCommandEv entArgs e)
{
// stop editing
dgis.EditItemIndex = -1;

switch (e.CommandName)
{
case "Insert":
break;

case "Update":
break;

case "Cancel":
EditCommandColumn ecc =(EditCommandColumn) dgis.Columns[0];
ecc.UpdateText = "Update";
EditCommandColumn ecc1 =(EditCommandColumn) dgis.Columns[0];
ecc.UpdateText = "Update";
break;

case "Edit":
// begin editing
dgis.EditItemIndex = e.Item.ItemIndex;
break;
}

// fill and bind
Fill();
Bind();
}

Feb 27 '07 #1
0 1099

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Frosty | last post by:
Howto make datagrid enforce rules of xml schema? Created xml schema in the designer. Constraints created there using the following <xs:simpleType name="zipcode"><xs:restriction...
2
by: Josef Meile | last post by:
Hi, I'm using a ComboBox, some Textboxes, and a DataGrid to represent a many-to-many relationship between Person and Course. Each time that I change the value in the ComboBox (which for now is...
2
by: zambizzi | last post by:
....I can't seem to get my hands on a control I'm loading in an editable datagrid. Here's my datagrid control: <asp:datagrid id="GLRulesGrid" runat="server" autogeneratecolumns="False"...
1
by: Dan11 | last post by:
here's C sharp code: Start code... private void searchBtn_Click(object sender, System.EventArgs e) { //For sqlCommand1 is a search by Wkst ID (employeeID on pubs) params if...
3
by: dbuchanan | last post by:
Hello, (Windows forms - SQL Server) I fill my datagrid with a stored procedure that includes relationships to lookup tables so that users can see the values of the combobox selections rather...
4
by: cooltech77 | last post by:
Hi, I am trying to build the following functionality in the datagrid. I have a lot of columns in the datagrid which are being populated from the database and the user needs to scroll...
0
by: Ambica Jain | last post by:
I have a data grid called Files, which has some columns like FileName, Col1, Col2, ... , Col8. Then i have a combobox which allows user to select from Col1 to Col8 and based on this selection, i...
9
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the...
8
by: Brock | last post by:
I am trying to populate a Crystal Report from data in my DataGrid. The reason for this is that I want the user to be able to change values without updating the database, but still have their report...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.