HI all,
i have binded data from database into a stringbulider table. Is it possible to edit the stringbuilder table. If yes how can we do that. Plz help.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Pradeep ChandrakerPosted Jun 22, 2011, 1:32 AM
Instead of using html table you need to use asp.net datagrid to provide edit functionality. Please go through below link for more details on how to implement edit/update/ delete functionality in datagrid.
http://www.c-sharpcorner.com/UploadFile/rahul4_saxena/BasicoperationsofDataGrid05022007081224AM/BasicoperationsofDataGrid.aspx
http://www.c-sharpcorner.com/UploadFile/lcamlibel/datagridwebcontrol02122007040915AM/datagridwebcontrol.aspx
http://www.codeproject.com/KB/aspnet/Edit_and_Delete_Data.aspx
Ruchi RPosted Jun 22, 2011, 1:18 AM
The above code binds the data from a database into a table. Now what i need to do is: there will be one edit button on a form. If a user check on a checkbox in table and Click on a edit button, he should be able to edit the respective data. Could you provide me a sample code if possible.
Pradeep ChandrakerPosted Jun 22, 2011, 1:05 AM
Also can you explain little bit more on what exactly you want to do. I see you are assigning StringBuilder variable ShowDetails into session, but wanted to know what exactly you want to edit, it will be good if you can provide some scenario.
Ruchi RPosted Jun 22, 2011, 12:52 AM
Here is my code for binding data in a stringbulider. The given below code binds data in a table. Now i need to edit those data when required. How is it possible to do?
protected void bindData()
{
StringBuilder ShowDetails = new StringBuilder();
divShow.Style.Add("display", "none");
string myquery = "select sId, sEmpName, dtYear, dtMonth, sSalary from tblSalarySheet where sStatus='A' and dtYear='"+ ddListYear.SelectedItem.Text +"' and dtMonth='"+ ddlistMonth.SelectedItem.Text +"'";
int rowNum = 1;
string conn = ConfigurationSettings.AppSettings["SqlConn"];
SqlConnection MyConn = new SqlConnection(conn);
SqlCommand cmd = new SqlCommand(myquery, MyConn);
SqlDataReader reader;
try
{
MyConn.Open();
reader = cmd.ExecuteReader();
if (reader.HasRows)
{
divShow.Style.Add("display", "block");
rowNum = 1;
while (reader.Read())
{
if (rowNum % 2 == 0)
ShowDetails.Append("
else
ShowDetails.Append("
ShowDetails.Append("
ShowDetails.Append("
ShowDetails.Append("
ShowDetails.Append("
ShowDetails.Append("
ShowDetails.Append("
"");
rowNum++;
ShowDetails.Append("
}
Session["sID"] = ShowDetails.ToString();
}
else
{
divShow.Style.Add("display", "none");
}
reader.Close();
}
catch
{
}
finally
{
MyConn.Close();
cmd.Dispose();
}
}
Pradeep ChandrakerPosted Jun 21, 2011, 10:43 AM
Guest UserPosted Jun 21, 2011, 8:11 AM