Last post Jul 23, 2009 06:53 PM by Rawler
Jul 22, 2009 11:31 PM|Rawler|LINK
Well I used to work with GridViews and SQLDataSources and get Seleted Row Values; now that I'm doing it via DataTables; everytime I try to get Rows data, theres only empty strings; how could I catch the selected row value before the postback, because it
becomes empty after it.
Thanks for reading!
GridView PostBack Row Cells
Jul 23, 2009 03:01 AM|melon.melon|LINK
Maybe this will help, it is in C#:
public DataTable GetDataTable (string connectionString)
SqlConnection sqlConnection = new SqlConnection(connectionString);
SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(“Select * from Table”, sqlConnection);
DataTable dataTable = new DataTable ("Country");
DataTableReader datatableReader = dataTable.CreateDataReader();
String connectionString = System.Web.Configuration..your connection string here;
DataTableReader dataTableReader = GetDataTable(connectionString);
found a post which may be useful to you:
Jul 23, 2009 03:12 PM|Rawler|LINK
Hi, well in fact I already fill the DataTable and bind it to the GridView, but as soon as I try to get the data inside the GridView it only shows me empty data; I guess this is because the postback and the GridView becomes empty after it. Here
the code as example...
Protected Sub consultoriosGridView_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles consultoriosGridView.SelectedIndexChanged
Dim row As GridViewRow = consultoriosGridView.SelectedRow
Call GuardaCita(row.Cells(2).Text, consultoriosListBox.SelectedValue, calendarioCalendar.SelectedDate, row.Cells(4).Text, row.RowIndex)
Here, as soon as a row is selected; I try to get the data from selected row, being the 2 and 4 columns the data I need to send; but its always empty, because of the postback I think...
Jul 23, 2009 06:53 PM|Rawler|LINK
it's solved, the problem was that this GridView has controls in it; so the cells were empty, but the controls inside (labels) got all the info.