From: JohnE on 4 Apr 2010 00:24 I have a page that is using a tab control. This tab control is showing all the information about a change request. Which includes other tables that are the many to the one record. An example would be the change request being initiated has an affect on ms office, sql server, ssrs, etc. One tab will have a gridview that will show the areas the request affects. The PK and FK are established between the tables. There is a dropdownlist above the tab control that when the request is selected, all the fields in the tab control (including the gridviews) show the info associated with the selected request. The ddl is using a sqldatasource. How do I go about having the gridview work along with the rest of the fields to show the information associated with the selected request? Thanks...John
From: Mark Rae [MVP] on 4 Apr 2010 02:25 "JohnE" <JohnE(a)discussions.microsoft.com> wrote in message news:BFD218CC-6B59-4676-894D-C3F0DEB604BA(a)microsoft.com... > I have a page that is using a tab control. This tab control is showing > all > the information about a change request. Which includes other tables that > are > the many to the one record. An example would be the change request being > initiated has an affect on ms office, sql server, ssrs, etc. One tab will > have a gridview that will show the areas the request affects. The PK and > FK > are established between the tables. There is a dropdownlist above the tab > control that when the request is selected, all the fields in the tab > control > (including the gridviews) show the info associated with the selected > request. > The ddl is using a sqldatasource. > > How do I go about having the gridview work along with the rest of the > fields > to show the information associated with the selected request? If I were doing this, I'd do the following: 1) Create a stored procedure to fetch the data for populating the GridView CREATE PROCEDURE MyProc @pID int AS SELECT * FROM MyTable WHERE ID = COLLATE(pID, ID) 2) Add the following to the DropDownList SelectedIndexChanged event protected void MyDDL_SelectedIndexChanged(object sender, EventArgs e) { SqlParameter objSqlParameter; List<SqlParameter> lstSqlParameters = new List<SqlParameter>(); objSqlParameter = new SqlParameter("@pID", SqlDbType.Int); objSqlParameter.IsNullable = true; objSqlParameter.Value = Convert.ToInt32(MyDDL.SelectedValue); lstSqlParameters .Add(objSqlParameter); MyGridView.DataSource = DAL.GetDataSet("MyProc", lstSqlParameters); MyGridView.DataBind(); } -- Mark Rae ASP.NET MVP http://www.markrae.net
|
Pages: 1 Prev: Inserting, updating, etc. for ListView with a custom data source Next: Update Panel inserting |