|
Yaar,
Please post only relevent code snippet ,
"itni ramayan kaun padhega "
|
|
|
|
|
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
//TextBox t= (TextBox )GridView1.Rows[e.RowIndex ].FindControl ("txtId");
//TextBox t2=(TextBox )GridView1.Rows[e.RowIndex ].FindControl ("txtName");
GridViewRow row = GridView1.Rows[e.RowIndex];
TextBox t = (TextBox)row.FindControl("txtId");
TextBox t2 = (TextBox)row.FindControl("txtName");
con.Open();
cmd = new OdbcCommand("update table AdminAddNewItem set Node_Name= '" + t2.Text + "' where Node_Id=" + t.Text, con);
cmd.ExecuteNonQuery();
con.Close();
|
|
|
|
|
Apart from the part where your code is broken and I can erase your entire database with it ?
What's happening with this code ? Why do you feel it needs correcting ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
|
Use stored procedure...or atleast use parametrised Query ,
Please don't write like this
|
|
|
|
|
Hi,
Please use the following line to access the data grid textbox value from code behind
Convert.ToString(CType(GridView1.Rows(i).FindControl("Text1"), Textbox).Text)
Thanks,
Raja.S
|
|
|
|
|
In a web based application i have some textboxes and on the button click the data from the textboxes should be displayed in a gridview or some other conrol where the data can be displayed, modified such that the data be sent back to the textboxes for modifying and back into the gridview .Another button for deleting the data and finally on the click of a button that is outside the gridview the data from it should go into the database.
I was able get the data into the gridview from the textboxes to the grid and back using the
select "textbox1.text" as data1,"textbox2.text"as data2 etc.and was able to modify the data.but for deleting the row i was not able to trace which row is getting deleted and am not able to sent the data to the database on the button click outside the gridview.What should I do? is there some way i can use the gridview itself for the same or i should use some other conrol ?
|
|
|
|
|
You can use a list of objects as a datasource. You don't need to use a database.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Why dont u store the IDs of the deleted records and during saving the grid to DB delete the records from DB using thoseIDs.
|
|
|
|
|
thanks for the reply..
if i used 2 link button and both have the same command name select on the selected index changed of the gridview i am not able to trace which button has been clicked if the delete or the modify.more over if i use the command name update for the delete button and call the GridView1_RowUpdating event i cannot retain the the gridview1.selectedrow.cells[1].text. for deleting where i update the delete status to be Yes.
As it is a web application on the button click outside the grid cannot retain the gridview1.SelectedRow.cells[0].text cannot be retreived and it throws an enception.
what should i do is there anything optional to a gridview.
Please reply soon
|
|
|
|
|
I tried your case,deleting the rows by clicking the delete button in each row.then i saved the PK of each row and finally during saving delete those rows by using the IDs.
I just put a column for ID which has the commandargument set to id,on delete event i was getting the IDs by this
int rowIndex = e.RowIndex;
LinkButton lnk = (LinkButton)GridView1.Rows[rowIndex].FindControl("lnkID");
Is it the case that u are searching or anything else.
|
|
|
|
|
thanks i will try it and tell you.
|
|
|
|
|
am sorry for the trouble am new to asp.net ,but as the data in the grid is not from the database but from the textboxes in the form.as the data is not actually in the database i cannot delete the row by using a query.That row has to be out of the grid as soon as i pess the delete button,add on the click of a button that is outside the gridview,i want all the data to go into the database.ie am using the gridview so that the user can modify any entry that he made in the textboxes and delete the rows that he wants and send it to the database later..
|
|
|
|
|
Hi All,
I want to connect Asp.net application with the my sql 5.0.please help me which driver need to be installed.
when i m tring to open the connection this is giving error
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
and my connection string is
string ConnStr = "Driver={MySQL ODBC 5.0 Driver};Server=localhost;Database=testwithdotnet;uid=root;pwd=password;Port=3306;Option=3";
and i installed this MySQL Connector Net 5.1.7 diver
Thanks and regards,
Amit Patel
|
|
|
|
|
I've never seen the driver specified in the connection string, I've just installed the right classes to deal with the data source, and used them.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
|
Hi All,
Thanks all . I have solved this problem
using following way
MySqlConnection con = new MySqlConnection(("server=127.0.0.1; user id=root; password=password; database=testwithdotnet; pooling=false;"));
Thanks and regards,
Amit Patel
modified on Tuesday, November 10, 2009 2:57 AM
|
|
|
|
|
Well, that's what we both told you to do, so....
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
|
Use the connector[^] provided by MySql folks.
Best wishes,
Navaneeth
|
|
|
|
|
hi ,
i m using this
string ConnStr = "Driver={MySQL ODBC 6.1.2 Driver};Server=localhost;Database=testwithdotnet;uid=root;pwd=password;Port=3306;Option=3";
OdbcConnection odbcConnection = new OdbcConnection(ConnStr);
OdbcCommand cmd = new OdbcCommand("SELECT * FROM amit", odbcConnection);
odbcConnection.Open();
but this is giving following error.
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
thanks and regards,
amit patel
|
|
|
|
|
Amit Patel1985 wrote: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
What makes you think this error is wrong ? What leads you to believe that the connection string is pointing to a valid driver ? Have you installed/configured one for ODBC ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi,
In my ASP.NET application, I have a situation where I am doing a lot of computing and database reads/inserts/updates.
I needed to gather statistics on the processing records. This info is actually displayed on another webpage. Processing routine looks something like this:
public void Process()
{
int recordCount = 0;
ProgressHelper.Start();
while(processing)
{
recordCount++;
if(recordCount % 10 == 0)
{
ProgressHelper.UpdateProcessedRecordCount(recordCount);
}
}
ProgressHelper.End();
}
These database calls to update the progress add additional delay.
I was wondering if there is a way to actually execute all the ProgressHelper stuff asynchronously (without using background worker)? (perhaps delegates ... but are delegates really async?)
|
|
|
|
|
What is ProgressHelper ?
BackgroundWorker is a class designed for windows applications not web applications. So using it in a web application is not a good idea. If I understood your question, you need to do a time consuming task on background and show a progress bar on another ASP.NET page, correct?
If yes, follow the below steps.- From the first page, start a thread (or better if you can use
ThreadPool ) and run the Process() method on that. - This method should update the progress to a session variable say
Session["progress"] - Once the thread started, redirect to the page where progress will be displayed
- Use AJAX and poll the
Session["progress"] value and show it on the page. For creating progress bar, you can use HTML DIV tag with a background color. You need to pass HttpContext.Current to the Process() method because it is thread specific and a worker thread won't have access to it. Use this context to access the session.
Hope that helps
Best wishes,
Navaneeth
|
|
|
|
|
Thanks Navaneeth. ProgressHelper is my internal DAL responsible for udpating the progress table (sorry I should have explained). I agree with you that BackgroundWorker is a bad idea that's why I was wondering if there might be a better way to accomplish this.
Also, what are your thoughts about Async Delegates? Have you seen any adverse effects of using them in ASP.NET?
Appreciate your hlep!
|
|
|
|