|
The entire html code is not sent back to the server. The only data that is sent to the server is the values in the fields in the form that is posted. If you have any data that you want to access from the server, you have to put it in form fields.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
hello,
i have a table which i'm populating it dynamically, i need to read th value of a specific cell i tried "tabel.Rows[1].Cells[1].Text" it's gaving me an empty value="";
i tried tr.Cells[1].Controls[0] it's not working also BUT while i'm testing it on the WATCH panel of VS 2003, when i wrote :
tr.Cells[1].Controls[0].Text it gave me the value i want, but the ".Text" can't be implemented in the code coz it's not exist!!
please if someone could help.
thank you
|
|
|
|
|
michael_jhons wrote: i tried "tabel.Rows[1].Cells[1].Text"
michael_jhons wrote: i tried tr.Cells[1].Controls[0]
Why would you try both of those? Don't you know what you put in the cells?
led mike
|
|
|
|
|
Dear Mike
maby i miss-explained what i want to do,
i have a table which contain a checkBox on the first cell of each TableRow, so foreach tableRow i'm checking if the the first cell is checked i read the value of the second cell so i can use it to delete A certain row from my database, so i must read the value.
please if you have an answer of my question, help me
thank you for your concern
|
|
|
|
|
michael_jhons wrote: so i must read the value.
What value? You still have not posted what you put in the Cell that you want to read? Don't you know?
led mike
|
|
|
|
|
the table is already populated its full of values i want to retreive that value.
here's the code:
foreach(TableRow tr in TbTariffTb.Rows)
{
TableCell cell = tr.Cells[0];
TableCell celCli=tr.Cells[1];
foreach (Control control in cell.Controls )
{
CheckBox checkBox = control as CheckBox;
if (checkBox != null)
{
if (checkBox.Checked)
{
}
}
}
}
|
|
|
|
|
michael_jhons wrote: the table is already populated its full of values
Populated how? Dude, you have now posted THREE times and you still have NOT SPECIFIED what you are putting in those cells that you want to read from. Without that information we can't help you. I'm done with you now, good luck.
led mike
|
|
|
|
|
your on a good way but there is a slight detail.
Your Code:
foreach(TableRow tr in TbTariffTb.Rows){TableCell cell = tr.Cells[0];TableCell celCli=tr.Cells[1];foreach (Control control in cell.Controls ){ CheckBox checkBox = control as CheckBox;if (checkBox != null){ if (checkBox.Checked) {
}}}}
My Advice
foreach(TableRow tr in TbTariffTb.Rows)
{
CheckBox checkBox = tr.FindControl("IDofYourCheckBox");
if (checkBox.Checked)
{
foreach (TableCell cell in tr.Cells)
{
String value = cell.Text;
}
String Value = tr.Cells[1].Text;
String Value2 = ((TextBox)tr.Cells[1].Controls[0]).Text;
}
}
|
|
|
|
|
ou might even have to cast:
CheckBox checkBox = (CheckBox)tr.FindControl("IDofYourCheckBox");
|
|
|
|
|
thank you a lot digimanus, i really apreciate your answer a lot
thank you
|
|
|
|
|
digimanus i tried all methods u gave me, which i alresdy tried it before
String Value2 = ((TextBox)tr.Cells[1].Controls[0]).Text;
an error occured it gives me: specified cast is not valid, do you think textbox is the control which has to be specified for this cell ?
thank you for your help
|
|
|
|
|
IS the row in Edit mode? (EditIndex > -1 in GridView)
Than use the above code
Else
String Value2 = tr.Cells[1].Text;
Otherwise.
Set a breakpoint on the line with the (TextBox) cast.
When reaching the breakpoint (Build = debug)
add a watch on
tr.Cells[1].Controls
See how many controls the Count gives. If larger than 1 try in the watch
all other controls in the array like
tr.Cells[1].Controls[1]
tr.Cells[1].Controls[2]
tr.Cells[1].Controls[and so on]
In that case you can see in which control your data exists.
Have Fun
|
|
|
|
|
it's alright i was populationg the cell by this method:
tablecell.Controls.Add(new LiteralControl(SomeString));
when i used tablecell.Text=SomeString;
it's working fine
Thanks for the help
|
|
|
|
|
Hi,
I have a DataGrid that have a dataset as a data source.
The dataset is being returned from a web service.
The code:
webservice.service1 srv = new webservice.service1();
DataSet ds = srv.GetDataSet();
Session["dataset"] = ds;
datagrid1.DataSource = Session["dataset"];
datagrid1.DataMember = "SomeTable";
datagrid1.DataBind();
When editing a row in the DataGrid the DataGrid is affected by the changes
but the DataSource remains the same as before the edit.
What is the problem ?
|
|
|
|
|
after setting the SelectedIndex, reload the DataSet again and bind it again to the datagrid.
|
|
|
|
|
When I do that, the DataGrid shows the old DataSet (before the edit)
|
|
|
|
|
What do you use to update the data in the database?
Stored Procedures?
Or is stating the DataSource method ApplyChanges() enough because of using other ways to communicate with the database ?
In other words. First update the data in the database before retrieving it again otherwise you are stuck with the original data.
|
|
|
|
|
I guess I wasnt clear enough, Ill try to describe the problem again.
The web service has two functions the first one retrives a DataSet and the second one gets DataSet
as a parameter and save it to the DataBase with DataAdapter.
After I get the DataSet from the web service I bind it to the DataGrid (as decribed In my first message)
when I make changes throgh the DataGrid I expect that the DataSet will change but it doesnt,
that's why its irrelevant to save it back in the DB at this stage.
Why does the DataSet doesn't change when I'm changing the DataGrid ?
|
|
|
|
|
It is very simple.
You are in disconnected state with the database. So after changing data in the gridview you have to change the data in the database. The webservice retrieves it data from the database. So after a change your webservice seems to run a type of reload data from the database.
After a change in a gridview you have to update the data in database.
your working order is:
Load data from database
Bind it to the grid
Edit a row
Update the data from the row in the database (You can use .SelectedValue property to see the DataKeyName and/or DataKeyValue. In that case you can update the row with the SelectedValue als key for the where)
After updating you load data again from the database
|
|
|
|
|
I dont want to change the DB every time I edit the DataGrid, I want to update the DB only after I press on "save" button.
The question is what I need to do so that when I edit the DataGrid the DataSet will be updated (without updating the DB yet, until I press the save button).
|
|
|
|
|
I do not think it would be wise to store your datatable in a session object. Would cost way too much memory.
Better to add a Safe button in each row of the gridview. After they press that safe button upload the data and reload.
|
|
|
|
|
Hi Guys,
I recently finished a project which i now need to, rewrite to a console app, allowing it to be linked to windows scheduler.
Is there anyway to convert a web app to a console app?
Or is it amatter of creating a new console app and breaking down the code and re writting it into the console app?
Any help feed back would be greatly appreciated.
Regards
DMC
|
|
|
|
|
DeanCook wrote: Or is it amatter of creating a new console app and breaking down the code and re writting it into the console app?
Yes. However if you followed standard Object Oriented Design Principles and Best Practices there won't be any re-writing, there would just be adding the original source files containing all the code for the application behavior into the new console project.
So did you?
led mike
|
|
|
|
|
Nooblet question. how do i go about doing that?
Regards DMC
|
|
|
|
|
Here's a tip for you. Voting down my posts is NOT the way get me to help you.
led mike
|
|
|
|