Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Datagrid BIG Problem Please Help

Reply
Thread Tools

Datagrid BIG Problem Please Help

 
 
Jonathan Dixon
Guest
Posts: n/a
 
      06-23-2004
Can someone tell me what is wrong here i am trying to get a datagrid to
populate from a datasource via and execute reader method, the sql is fine as
i have tested it but it does not put anything in the datagrid


private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs
e)

{


casedirectory = DataGrid1.SelectedItem.Cells[1].Text;


NameValueCollection col = ConfigurationSettings.AppSettings;

String strConnection = col.Get("odbcConnection1.ConnectionString");


OdbcConnection objConnection = new OdbcConnection(strConnection);

String strSQL = "SELECT MH_ID, MH_DESCRIPTION, DIR_NAME, MH_notes, MH_DATE
FROM tblMH WHERE DIR_NAME=" + "'" + casedirectory + "'";

OdbcCommand objCommand = new OdbcCommand(strSQL, objConnection);

objConnection.Open();

OdbcDataReader objDataReader;

objDataReader = objCommand.ExecuteReader();

if (objDataReader != null)

{

DataGrid2.DataSource = objDataReader;

DataGrid2.DataBind();

objDataReader.Close();

objConnection.Close();

}


 
Reply With Quote
 
 
 
 
Scott M.
Guest
Posts: n/a
 
      06-23-2004
All your code for connecting to the database and setting the datagrid's
datasource should be in the page_load event handler, not the
selectedIndexChanged event handler.


"Jonathan Dixon" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Can someone tell me what is wrong here i am trying to get a datagrid to
> populate from a datasource via and execute reader method, the sql is fine

as
> i have tested it but it does not put anything in the datagrid
>
>
> private void DataGrid1_SelectedIndexChanged(object sender,

System.EventArgs
> e)
>
> {
>
>
> casedirectory = DataGrid1.SelectedItem.Cells[1].Text;
>
>
> NameValueCollection col = ConfigurationSettings.AppSettings;
>
> String strConnection = col.Get("odbcConnection1.ConnectionString");
>
>
> OdbcConnection objConnection = new OdbcConnection(strConnection);
>
> String strSQL = "SELECT MH_ID, MH_DESCRIPTION, DIR_NAME, MH_notes, MH_DATE
> FROM tblMH WHERE DIR_NAME=" + "'" + casedirectory + "'";
>
> OdbcCommand objCommand = new OdbcCommand(strSQL, objConnection);
>
> objConnection.Open();
>
> OdbcDataReader objDataReader;
>
> objDataReader = objCommand.ExecuteReader();
>
> if (objDataReader != null)
>
> {
>
> DataGrid2.DataSource = objDataReader;
>
> DataGrid2.DataBind();
>
> objDataReader.Close();
>
> objConnection.Close();
>
> }
>
>



 
Reply With Quote
 
 
 
 
Jonathan Dixon
Guest
Posts: n/a
 
      06-24-2004
The data grid stuff is in the selectedindexchanged event as i only want it
to be bound to the datasource when someone has clicked on an entry in the
previous datagrid which then calls the selected indexchanged and then should
bind the second data grid.

Is it possible to do that or not, the datagrid is binding but not showing
any data in the datagrid only the headers


 
Reply With Quote
 
Scott M.
Guest
Posts: n/a
 
      06-24-2004
Oh, you have 2 datagrids...You should give us ALL your code to take a look
at then.


"Jonathan Dixon" <(E-Mail Removed)> wrote in message
news:uWseQ%(E-Mail Removed)...
> The data grid stuff is in the selectedindexchanged event as i only want it
> to be bound to the datasource when someone has clicked on an entry in the
> previous datagrid which then calls the selected indexchanged and then

should
> bind the second data grid.
>
> Is it possible to do that or not, the datagrid is binding but not showing
> any data in the datagrid only the headers
>
>



 
Reply With Quote
 
Jonathan Dixon
Guest
Posts: n/a
 
      07-01-2004
Thanks i got it sorted !


"Scott M." <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Oh, you have 2 datagrids...You should give us ALL your code to take a look
> at then.
>
>
> "Jonathan Dixon" <(E-Mail Removed)> wrote in message
> news:uWseQ%(E-Mail Removed)...
> > The data grid stuff is in the selectedindexchanged event as i only want

it
> > to be bound to the datasource when someone has clicked on an entry in

the
> > previous datagrid which then calls the selected indexchanged and then

> should
> > bind the second data grid.
> >
> > Is it possible to do that or not, the datagrid is binding but not

showing
> > any data in the datagrid only the headers
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GIDS 2009 .Net:: Save Big, Win Big, Learn Big: Act Before Dec 29 2008 Shaguf ASP .Net 0 12-26-2008 09:29 AM
GIDS 2009 .Net:: Save Big, Win Big, Learn Big: Act Before Dec 29 2008 Shaguf ASP .Net Web Controls 0 12-26-2008 06:11 AM
GIDS 2009 Java:: Save Big, Win Big, Learn Big: Act Before Dec 29 2008 Shaguf Python 0 12-24-2008 07:35 AM
GIDS 2009 Java:: Save Big, Win Big, Learn Big: Act Before Dec 29 2008 Shaguf Ruby 0 12-24-2008 05:07 AM
Big DataGrid Update Problem-MVP Help Please???? steroche ASP .Net 4 08-25-2005 08:38 PM



Advertisments