|
|
Comments and Discussions
|
|
 |

|
Where does the line of code came from?
"ContactTableAdapter contact = new ContactTableAdapter();"
Sorry, but this is not at all understandable. can you pl throw some light?
|
|
|
|
|
|

|
Hi Ashrafur,
I got problem when accessing my page with editable grid and dataset.
It give me http error 404 - file or directory not found.
which is very strange, it is only on the page that contain editable grid+dataset.
And is only happen on remote, I can access it perfectly in localhost.
Is there anything that we should setup on IIS ? or is there something wrong on my code ?
or is it open some port except 80 (internet port) and mssql port ?
Janu
|
|
|
|

|
At the moment I am getting 5 Errors (Using Oracle Database 11.2.0.1)
This is how I created tables and inserted rows :
create table contact
(
id number not null,
name varchar2(50) not null,
sex varchar2(6) not null,
type varchar2(50) not null,
isactive number(1),
constraint pk_contact_1 primary key (id)
)
/
insert into contact values (1,'Girish','Male','Business',1);
create table contacttype
(
id number not null,
typename varchar2(20),
constraint pk_contacttype primary key (id)
)
/
insert into contacttype values (1,'Friend');
insert into contacttype values (2,'Regular');
insert into contacttype values (3,'Family');
insert into contacttype values (4,'Business');
insert into contacttype values (5,'Personal');
I am using Visual Studio 2012 on Windows 8 Ultimate Virtual Machine :
Error 1 'ASP.default_aspx' does not contain a definition for 'GridView1_SelectedIndexChanged' and no extension method 'GridView1_SelectedIndexChanged' accepting a first argument of type 'ASP.default_aspx' could be found (are you missing a using directive or an assembly reference?) C:\Users\gk\Documents\My Web Sites\WebSite1\WebSite\EditableGrid\Default.aspx 12
I just added below line so above error gone : (I don't know why empty sub required though.
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
Error 2 'DataSetTableAdapters.CONTACTTYPETableAdapter' does not contain a definition for 'GetTypeById' and no extension method 'GetTypeById' accepting a first argument of type 'DataSetTableAdapters.CONTACTTYPETableAdapter' could be found (are you missing a using directive or an assembly reference?) C:\Users\gk\Documents\My Web Sites\WebSite1\WebSite\EditableGrid\Default.aspx.cs 53 52 WebSite1/WebSite/EditableGrid
Line 53 is :
protected void of GridView1_RowDataBound. In which there is :
lblType.Text = (string)contactType.GetTypeById(typeId);
So, it is showing error for GetTypeById.
Kindly tell me what to do?
Error 3 The best overloaded method match for 'DataSetTableAdapters.ContactTableAdapter.Update(string, string, string, short?, decimal)' has some invalid arguments C:\Users\gk\Documents\My Web Sites\WebSite1\WebSite\EditableGrid\Default.aspx.cs 87 9 WebSite1/WebSite/EditableGrid
Line 87 is :
protected void of GridView1_RowUpdating. In which there is :
contact.Update(txtName.Text, ddlSex.SelectedValue, cmbType.SelectedValue, flag, Convert.ToInt32(lblId.Text));
So, it is showing error for contact.
Kindly tell me what to do?
Error 4 Argument 4: cannot convert from 'bool' to 'short?' C:\Users\gk\Documents\My Web Sites\WebSite1\WebSite\EditableGrid\Default.aspx.cs 87 83 WebSite1/WebSite/EditableGrid
Same line number 87 :
contact.Update(txtName.Text, ddlSex.SelectedValue, cmbType.SelectedValue, flag, Convert.ToInt32(lblId.Text));
Kindly tell me what to do?
Error 5 No overload for method 'Insert' takes 4 arguments C:\Users\gk\Documents\My Web Sites\WebSite1\WebSite\EditableGrid\Default.aspx.cs 110 13 WebSite1/WebSite/EditableGrid
Line 110 is :
protected void of GridView1_RowCommand :
contact.Insert(txtNewName.Text, ddlNewSex.SelectedValue, cmbNewType.SelectedValue, flag);
and showing error for contact.
Kindly tell me what to do? Please tell me if I am missing anything important.
Thanks and Regards
Girish Sharma
|
|
|
|

|
What if I wish to hide insert option, when I am editing the row ? I mean, if I clicks editing the row, then new row insert option should be invisible. Is that possible please?
Thanks and Regards
Girish Sharma
|
|
|
|

|
Hi
Thanks for the great article.........Could you please provide definition of ContactTypeTableAdapter
|
|
|
|

|
Hi,
I've made some change on your code.
I have put button on FooterRow that will pop up window and then send some return value.
I have manage send these return value to web form (outside gridview).
My question is how can I send these return value to your editable gridview (let's say to textbox on footer row) ?
here my code
On my parent code behind:
------------
protected void grdContact_RowCommand(object sender, GridViewCommandEventArgs e)
{
SalesLineTableAdapter xNUP = new SalesLineTableAdapter();
int flag = 0;
//bool flag= false;
if (e.CommandName.Equals("Insert"))
{
DropDownList ddlNewKodeItem = (DropDownList)grdContact.FooterRow.FindControl("ddlNewItemCode");
TextBox txtNewJml = (TextBox)grdContact.FooterRow.FindControl("txtNewJml");
TextBox txtNewHarg = (TextBox)grdContact.FooterRow.FindControl("txtNewHarga");
//DropDownList ddlNewKodeGrade = (DropDownList)grdContact.FooterRow.FindControl("ddlNewKodeGrade");
CheckBox chkNewActive = (CheckBox)grdContact.FooterRow.FindControl("chkNewActive");
if (chkNewActive.Checked) flag = 1; else flag = 0;
xNUP.InsertSales(DocSO, DocInv, DateTime.Now, "", ddlNewKodeItem.SelectedValue, "", Convert.ToDecimal(txtNewJml.Text.ToString()), Convert.ToDecimal(txtNewHarg.Text.ToString()), 0, 0, 0);
updateInvent(cboKodePaket.SelectedValue, ddlNewKodeItem.SelectedValue, Convert.ToDecimal(txtNewJml.Text.ToString()));
FillGrid();
}
if (e.CommandName.Equals("Cari"))
{
TextBox txtItem = (TextBox)grdContact.FooterRow.FindControl("txtNewItem");
Page.ClientScript.RegisterStartupScript(Type.GetType("System.String"), "AddScript", "openItem('" + txtItem.Text + "')", true);
}
}
------------
On My parent script:
<script type="text/javascript">
function upItem(value1,value2,value3,value4)
{
document.form1.txtValue1.value = value1;
document.form1.txtValue2.value = value2;
document.form1.txtValue3.value = value3;
document.form1.txtValue4.value = value4;
}
function openItem(text)
{
var retIval=' ';
retIval = window.open('PopItem.aspx?ItemName=' + text ,'','status,height=500,width=800');
}
</script>
-------------
On My Child Script:
----------------
<script type='text/javascript'>
function SetData(ItemCode, ItemName, Satuan, HargaJual)
{
document.form1.txtTest.value = ItemCode;
window.opener.upItem(ItemCode,ItemName,Satuan,HargaJual);
window.close();
window.focus=false;
return false;
}
</script>
|
|
|
|
|

|
Thank you Ashrafur - this was very helpful
|
|
|
|

|
My vote of 5 goes because of the detailing the article provides.
|
|
|
|

|
for every click you have to go in server side...
|
|
|
|

|
nice
|
|
|
|
|

|
I have an excel file and have data exported to sql and I want to edit update and delete data for the row can you help me with the code.
jignesh
|
|
|
|

|
In this code i can't find the dropdownlist in edit itemplate to edit,can you pls suggest me as soon as possible
|
|
|
|

|
I can't find the dropdownlist in edititemplate
|
|
|
|

|
Hello Ashrafur,
I found your example code very interesting, but found some limitations...
If I have a 1000 users DB and only would like to display 10 por page, how could I do that, without loading all the DB and then just stopping at the 10th row display? The idea is to use the LIMIT command in SQL, specifying the start and end of the selection.
Additionally, if I wanted to get the total rows, is it possible to do it without loading the whole data? Because it but by loading the same the Data:
ContactTableAdapter contact = new ContactTableAdapter();
DataTable contacts = contact.GetData();
double pages = Math.Ceiling((double)contacts.Rows.Count/10);
lblTotalPages.Text = System.Convert.ToString(pages);
That gets all the records downloaded from the DB, doesn't it?
Finally, I'm new to VS and C#, if I may ask, how do you get the XSD file generated if I wanted to add more columns to the update and insert queries? I added more columns to the Contact DB and had to modify the Insert and Update commands manually in the XSD file...
Thank you very much, Is it possible or I can only do that by switching to ADO.NET or Linq.
|
|
|
|

|
So I'm using this for for a project at work and I've got two footer rows for inserting. I have no idea why this happens, I've been fiddling with it for a few hours now and I've got nothing. The bottom most insert row is in italics and when I use ShowFooter="false" it gets rid of both insert rows. Any suggestions? Any help would be super appreciated.
Edit: Oh, and the 2nd footer row also adds a coma after whatever I input into it. This behavior is just silly.
modified 12 Jul '12 - 11:30.
|
|
|
|

|
nice succint article..thanks!!!
|
|
|
|

|
Critical Component is MISSING.
TestDatabaseTableAdapters not found.
NO Solution (SLN) file is included with the source code!
Great idea... just unusable for me!
|
|
|
|

|
I was having trouble figuring out how to create a template field with a drop-down list that displayed one value but stored another. This gave me just what I needed. Thanks!
|
|
|
|

|
Can you post the SQL DB Creation Script for the Database used for this Article ?
I am unable to connect to the database named "TestDatabase", since I do not have the DB:-
Cannot open database "TestDatabase" requested by the login. The login failed.
Login failed for user 'MyPCName\SQLInstanceName'.
Sincerely,
Muzaffar Ali Rana.
|
|
|
|

|
hi,i have done a code similar to yours but facing a problem when i m clicking an edit button,on first click the page is loading and on second click edit templetes are getting visible,this prob is due to the fact that i m writing bind() method in (!Page.Postback).when i m writing that method outside the (!Page.Postback) edit templetes are visible but during the update its taking previous value
|
|
|
|

|
I have followed all the instructions you've listed, but when I try to build this, i get this error The type or namespace name 'TestDatabaseTableAdapters' could not be found.
I am using VS 2010. I have tried building in 2.0, 3.5, and 4 and I still get this error. Can you please help?
|
|
|
|

|
Could be great article if you put example database generation script into the source code. Or reworked it to ship with ms access db.
|
|
|
|
|

|
Good Article....Would have explained more...
|
|
|
|

|
Where is the code of Contact Table Adapter?? Please GIve it to me.. Tnx
|
|
|
|

|
nice explanation...
thanks for sharing.
|
|
|
|
|

|
Hi. Im fairly new to certain aspects of Asp. I usually create grids using sqlDataSource, etc, but I want to learn about creating grids on the fly so was pleased to find your article. I downloaded the source and established a new 'website' through vs2008 to test this. All your folders and code etc were placed within the site and I thought great now lets start learning - ran the page and received an error on this line .... this.Adapter.Fill(dataTable); The error is Invalid Object name 'Contact'. Being New to this method I created a database called 'Contact' just in case it was looking for that, but that didn't resolve the issue and I can't see what else I am missing.
Can you help me by explaining what else I need to do to fire your example? Obviously, its something simple as others seem to have it working.
Thank you for your time
Regards
|
|
|
|

|
Hello Ashrafur Rahaman
where is the Class or Assembly ContactTableAdapter please send me or update it in your artical I need this very urgently
Manjeet_24_singh@yahoo.co.in
Thanks
manjeet
|
|
|
|

|
hello sir
i got first assignment in my office and m doing d same editable Gridview using microsost Access data base.
but
i had pro blame while using Editable Grid view you used .xsd and in bellow code you used GetTypeById(typeId).
how can i decleared GetTypeId in another way b'coz i don't have .xsd file
protected void grdContact_RowDataBound(object sender, GridViewRowEventArgs e)
{
ContactTypeTableAdapter contactType = new ContactTypeTableAdapter();
DataTable contactTypes = contactType.GetData();
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lblType = (Label)e.Row.FindControl("lblType");
if (lblType != null)
{
int typeId = Convert.ToInt32(lblType.Text);
lblType.Text = (string)contactType.GetTypeById(typeId);
}
need urgent i'hv to submit my assignment soon.
|
|
|
|
|

|
An article is explained in very simple way so that beginner can also get very easily.
|
|
|
|

|
Hello Sir,
am new in .Net hv one question in Grid view How following code come in aspx page
SelectedValue='<%# Eval("Sex") %>' Eval is not generated when i am binding to grid.
which property u r using or wot property u assign? kindly guide me becuase at edit time value ll not chance.
Regards
Priyanka
|
|
|
|
|
|

|
I have been recently working on a project that required a very stylable inline edit grid that has no special buttons for "Update"/"Edit".
Nice to see other people accomplishing simillar goals, I might improve my own grid based on some of the things you have done in yours!
Kyryll's blog[^]
|
|
|
|
|

|
Hi
Ive been having problems getting your example to work.
using TestDatabaseTableAdapters;
The type or namespace name 'TestDatabaseTableAdapters' could not be found (are you missing a using directive or an assembly reference?)
This is causing an error. Ive added the file TestDatabase from the App_Code folder and its created several files
but still cant get it to work.
Could you upload a complete working example solution rather than the Default page and the data?
Thanks
AP
|
|
|
|

|
Very educational, to me was very helpful, and I am new to asp. MEX
|
|
|
|
|
|

|
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
|
|
|
|

|
How To Edit Grid View In Asp.net Using VB....
Pls Reply To King _rav@rediffmail.com
Pls Sir...
|
|
|
|

|
First: Tks for your time ....
How Can I hide the last row "Add new/ Insert" when the user is editing another row?
Tks for you answer...
|
|
|
|

|
This article is useless without database script.
|
|
|
|

|
I downloaded your gr8 article but where is the database schema? whats the use if I am not able to run the app?
Thanks and Regards.
Jaggi
S:http://jagsmcp.spaces.live.com/
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
This article will give you an overview of how to use an ASP.NET GridView completely, and how to use RowEditing, RowUpdating, RowDeleting, RowCommand, RowDataBound, RowCancelingEdit, and Pagination in a DataGrid. From this article, you will have a clear view of GridView data inserting, deleting, and
| Type | Article |
| Licence | CPOL |
| First Posted | 6 Feb 2008 |
| Views | 570,316 |
| Downloads | 30,148 |
| Bookmarked | 171 times |
|
|