Hi,
I need to display columns in a data grid based on 7 different queries. Now I
have 32 questions:
1. Is it possble to have 1 single data adapter with 7 queries & 1 data set
or do I need to have a separate data adapter & a separate data set for each
select query?
If thats possible then how?
2. I have the following code which allows the user to enter an order number
& click the view button which should show all information for that
order...But the data gris is not showing the infomation, it is showing the
only the column headings... I am using only 1 data grid for all the
queries... Everytime a different view link (related to a different criteria)
is clicked , I change the DataSource , DataKeyField & DataMember for the grid
which points to a separate data set.
Code ::
private void LinkButton1_Click(object sender, System.EventArgs e)
{
sqlDataAdapter1.Fill(dsAllAO1);
DataGrid1.DataBind();
}
private void lnkByOrder_Click(object sender, System.EventArgs e)
{
sqlSelectCommand2.Parameters["@o"].Value=txtOrder.Text;
// Different data set
sqlDataAdapter2.Fill(dsByOrder1); DataGrid1.DataSource=
dsByOrder1;
DataGrid1.DataMember="INVOICES";
DataGrid1.DataKeyField= "ORDER_NO";
DataGrid1.AutoGenerateColumns=true;
DataGrid1.DataBind();
}
private void lnkByName_Click(object sender, System.EventArgs e)
{
sqlSelectCommand2.Parameters["@n"].Value=txtName.Text;
// Different data set
sqlDataAdapter2.Fill(dsByName1); DataGrid1.DataSource=
dsByName1;
DataGrid1.DataMember="INVOICES";
DataGrid1.DataKeyField= "ORDER_NO";
DataGrid1.AutoGenerateColumns=true;
DataGrid1.DataBind();
}
Is smthg wrong with this code? Will the data grid not work if I bound it to
a different data set on different link button clicks?
Thanks
--
pmud 5 2244
pmud wrote: Hi,
I need to display columns in a data grid based on 7 different queries. Now I have 32 questions:
1. Is it possble to have 1 single data adapter with 7 queries & 1 data set or do I need to have a separate data adapter & a separate data set for each select query? If thats possible then how?
Yes, you can have 1 single adapter with 7 different queries and 1 data
set. It all depends on how your stored procedure is written. If there
are 7 select statements or unions or whatever, you will get back 7
tables in one stored procedure call that you can then populate into a
data set using the data adapter. 2. I have the following code which allows the user to enter an order number & click the view button which should show all information for that order...But the data gris is not showing the infomation, it is showing the only the column headings... I am using only 1 data grid for all the queries... Everytime a different view link (related to a different criteria) is clicked , I change the DataSource , DataKeyField & DataMember for the grid which points to a separate data set.
Code ::
private void LinkButton1_Click(object sender, System.EventArgs e) { sqlDataAdapter1.Fill(dsAllAO1); DataGrid1.DataBind(); }
private void lnkByOrder_Click(object sender, System.EventArgs e) { sqlSelectCommand2.Parameters["@o"].Value=txtOrder.Text;
// Different data set sqlDataAdapter2.Fill(dsByOrder1); DataGrid1.DataSource= dsByOrder1; DataGrid1.DataMember="INVOICES"; DataGrid1.DataKeyField= "ORDER_NO"; DataGrid1.AutoGenerateColumns=true; DataGrid1.DataBind(); }
private void lnkByName_Click(object sender, System.EventArgs e) { sqlSelectCommand2.Parameters["@n"].Value=txtName.Text;
// Different data set sqlDataAdapter2.Fill(dsByName1); DataGrid1.DataSource= dsByName1; DataGrid1.DataMember="INVOICES"; DataGrid1.DataKeyField= "ORDER_NO"; DataGrid1.AutoGenerateColumns=true; DataGrid1.DataBind(); }
Is smthg wrong with this code? Will the data grid not work if I bound it to a different data set on different link button clicks?
Your code above should run fine, but here is something a little leaner
and easier to debug:
<code>
private void BindData(string sqlQuery, string paramName, object paramValue)
{
DataTable queryTable = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter(sqlQuery, connection);
sda.SelectCommand.CommandType = CommandType.StoredProcedure;
if(paramName != null && paramValue != null)
{
sda.SelectCommand.Paramaters.Add(paramName, paramValue);
}
sda.Fill(queryTable);
DataGrid1.DataSource = queryTable;
DataGrid1.DataKeyField = "ORDER_NO";
DataGrid1.AutoGenerateColumns=true;
DataGrid1.DataBind();
}
</code>
Then, elsewhere in your code, all you would have to do to populate your
datagrid is to just call
private void lnkByName_Click(object sender, System.EventArgs e)
{
// sqlSelectCommand2.Parameters["@n"].Value=txtName.Text;
// // Different data set
// sqlDataAdapter2.Fill(dsByName1);
// DataGrid1.DataSource= dsByName1;
// DataGrid1.DataMember="INVOICES";
// DataGrid1.DataKeyField= "ORDER_NO";
// DataGrid1.AutoGenerateColumns=true;
// DataGrid1.DataBind();
//Replace above with:
BindData("<stored proc name>", "@n", txtName.Text);
} Thanks
hth,
~d
Hi D.W. Warlock
I have never written stored procedures. but just now I did a tutorial on
them. So I should write a stored procedure with 7 select statements . Then I
use this stored procedure with only one data adapter & 1 data set. & when
the user clicks the view button , the data grid will show the result? Is that
right?
"D.W. Warlock" wrote: pmud wrote: Hi,
I need to display columns in a data grid based on 7 different queries. Now I have 32 questions:
1. Is it possble to have 1 single data adapter with 7 queries & 1 data set or do I need to have a separate data adapter & a separate data set for each select query? If thats possible then how?
Yes, you can have 1 single adapter with 7 different queries and 1 data set. It all depends on how your stored procedure is written. If there are 7 select statements or unions or whatever, you will get back 7 tables in one stored procedure call that you can then populate into a data set using the data adapter.
2. I have the following code which allows the user to enter an order number & click the view button which should show all information for that order...But the data gris is not showing the infomation, it is showing the only the column headings... I am using only 1 data grid for all the queries... Everytime a different view link (related to a different criteria) is clicked , I change the DataSource , DataKeyField & DataMember for the grid which points to a separate data set.
Code ::
private void LinkButton1_Click(object sender, System.EventArgs e) { sqlDataAdapter1.Fill(dsAllAO1); DataGrid1.DataBind(); }
private void lnkByOrder_Click(object sender, System.EventArgs e) { sqlSelectCommand2.Parameters["@o"].Value=txtOrder.Text;
// Different data set sqlDataAdapter2.Fill(dsByOrder1); DataGrid1.DataSource= dsByOrder1; DataGrid1.DataMember="INVOICES"; DataGrid1.DataKeyField= "ORDER_NO"; DataGrid1.AutoGenerateColumns=true; DataGrid1.DataBind(); }
private void lnkByName_Click(object sender, System.EventArgs e) { sqlSelectCommand2.Parameters["@n"].Value=txtName.Text;
// Different data set sqlDataAdapter2.Fill(dsByName1); DataGrid1.DataSource= dsByName1; DataGrid1.DataMember="INVOICES"; DataGrid1.DataKeyField= "ORDER_NO"; DataGrid1.AutoGenerateColumns=true; DataGrid1.DataBind(); }
Is smthg wrong with this code? Will the data grid not work if I bound it to a different data set on different link button clicks?
Your code above should run fine, but here is something a little leaner and easier to debug:
<code> private void BindData(string sqlQuery, string paramName, object paramValue) { DataTable queryTable = new DataTable(); SqlDataAdapter sda = new SqlDataAdapter(sqlQuery, connection); sda.SelectCommand.CommandType = CommandType.StoredProcedure; if(paramName != null && paramValue != null) { sda.SelectCommand.Paramaters.Add(paramName, paramValue); } sda.Fill(queryTable); DataGrid1.DataSource = queryTable; DataGrid1.DataKeyField = "ORDER_NO"; DataGrid1.AutoGenerateColumns=true; DataGrid1.DataBind(); } </code>
Then, elsewhere in your code, all you would have to do to populate your datagrid is to just call
private void lnkByName_Click(object sender, System.EventArgs e) { // sqlSelectCommand2.Parameters["@n"].Value=txtName.Text; // // Different data set // sqlDataAdapter2.Fill(dsByName1); // DataGrid1.DataSource= dsByName1; // DataGrid1.DataMember="INVOICES"; // DataGrid1.DataKeyField= "ORDER_NO"; // DataGrid1.AutoGenerateColumns=true; // DataGrid1.DataBind();
//Replace above with: BindData("<stored proc name>", "@n", txtName.Text); }
Thanks
hth, ~d
Hi D.W. Warlock,
I created a stored procedure which works fine when i run it from the server
explorer.
Stored Procedure Code::
CREATE PROCEDURE dbo.usp_Order (@OrderNo int) AS
select * from IRUS_INVOICES where ORDER_NO = @OrderNo
GO
& then I used the followng code...
private void BindData(string sqlQuery, string paramName, object paramValue)
{
DataTable queryTable = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter(sqlQuery, sqlConnection1);
sda.SelectCommand.CommandType = CommandType.StoredProcedure;
if(paramName != null && paramValue != null)
{
//sda.SelectCommand.Paramaters.Add(paramName, paramValue);
sda.SelectCommand.Parameters.Add(paramName, paramValue);
}
sda.Fill(queryTable);
DataGrid1.DataSource = queryTable;
DataGrid1.DataKeyField = "ORDER_NO";
DataGrid1.AutoGenerateColumns=true;
DataGrid1.DataBind();
}
private void lnkByOrder_Click(object sender, System.EventArgs e)
{
BindData("dbo.usp_Order", "@OrderNo",
int.Parse(txtOrder.Text));
}
But when I click the view link , the data grid doesnt show up the records
.... What is wrong with the code?
"D.W. Warlock" wrote: pmud wrote: Hi,
I need to display columns in a data grid based on 7 different queries. Now I have 32 questions:
1. Is it possble to have 1 single data adapter with 7 queries & 1 data set or do I need to have a separate data adapter & a separate data set for each select query? If thats possible then how?
Yes, you can have 1 single adapter with 7 different queries and 1 data set. It all depends on how your stored procedure is written. If there are 7 select statements or unions or whatever, you will get back 7 tables in one stored procedure call that you can then populate into a data set using the data adapter.
2. I have the following code which allows the user to enter an order number & click the view button which should show all information for that order...But the data gris is not showing the infomation, it is showing the only the column headings... I am using only 1 data grid for all the queries... Everytime a different view link (related to a different criteria) is clicked , I change the DataSource , DataKeyField & DataMember for the grid which points to a separate data set.
Code ::
private void LinkButton1_Click(object sender, System.EventArgs e) { sqlDataAdapter1.Fill(dsAllAO1); DataGrid1.DataBind(); }
private void lnkByOrder_Click(object sender, System.EventArgs e) { sqlSelectCommand2.Parameters["@o"].Value=txtOrder.Text;
// Different data set sqlDataAdapter2.Fill(dsByOrder1); DataGrid1.DataSource= dsByOrder1; DataGrid1.DataMember="INVOICES"; DataGrid1.DataKeyField= "ORDER_NO"; DataGrid1.AutoGenerateColumns=true; DataGrid1.DataBind(); }
private void lnkByName_Click(object sender, System.EventArgs e) { sqlSelectCommand2.Parameters["@n"].Value=txtName.Text;
// Different data set sqlDataAdapter2.Fill(dsByName1); DataGrid1.DataSource= dsByName1; DataGrid1.DataMember="INVOICES"; DataGrid1.DataKeyField= "ORDER_NO"; DataGrid1.AutoGenerateColumns=true; DataGrid1.DataBind(); }
Is smthg wrong with this code? Will the data grid not work if I bound it to a different data set on different link button clicks?
Your code above should run fine, but here is something a little leaner and easier to debug:
<code> private void BindData(string sqlQuery, string paramName, object paramValue) { DataTable queryTable = new DataTable(); SqlDataAdapter sda = new SqlDataAdapter(sqlQuery, connection); sda.SelectCommand.CommandType = CommandType.StoredProcedure; if(paramName != null && paramValue != null) { sda.SelectCommand.Paramaters.Add(paramName, paramValue); } sda.Fill(queryTable); DataGrid1.DataSource = queryTable; DataGrid1.DataKeyField = "ORDER_NO"; DataGrid1.AutoGenerateColumns=true; DataGrid1.DataBind(); } </code>
Then, elsewhere in your code, all you would have to do to populate your datagrid is to just call
private void lnkByName_Click(object sender, System.EventArgs e) { // sqlSelectCommand2.Parameters["@n"].Value=txtName.Text; // // Different data set // sqlDataAdapter2.Fill(dsByName1); // DataGrid1.DataSource= dsByName1; // DataGrid1.DataMember="INVOICES"; // DataGrid1.DataKeyField= "ORDER_NO"; // DataGrid1.AutoGenerateColumns=true; // DataGrid1.DataBind();
//Replace above with: BindData("<stored proc name>", "@n", txtName.Text); }
Thanks
hth, ~d
Hi pmud,
Sorry about the delay in getting back to you, I was out sick.
Anyhow, when you call "BindData("dob.usp_Order", "@OrderNo",
int.Parse(txtOrder.Text));" drop the dbo. in the stored procedure name.
For some reason that I have yet to find out, SqlServer/MSDE has issues
when using owner.spname conventions.
HTH,
~d
pmud wrote: Hi D.W. Warlock,
I created a stored procedure which works fine when i run it from the server explorer.
Stored Procedure Code:: CREATE PROCEDURE dbo.usp_Order (@OrderNo int) AS select * from IRUS_INVOICES where ORDER_NO = @OrderNo GO
& then I used the followng code... private void BindData(string sqlQuery, string paramName, object paramValue) { DataTable queryTable = new DataTable(); SqlDataAdapter sda = new SqlDataAdapter(sqlQuery, sqlConnection1); sda.SelectCommand.CommandType = CommandType.StoredProcedure; if(paramName != null && paramValue != null) { //sda.SelectCommand.Paramaters.Add(paramName, paramValue); sda.SelectCommand.Parameters.Add(paramName, paramValue); } sda.Fill(queryTable); DataGrid1.DataSource = queryTable; DataGrid1.DataKeyField = "ORDER_NO"; DataGrid1.AutoGenerateColumns=true; DataGrid1.DataBind(); }
private void lnkByOrder_Click(object sender, System.EventArgs e) { BindData("dbo.usp_Order", "@OrderNo", int.Parse(txtOrder.Text));
}
But when I click the view link , the data grid doesnt show up the records ... What is wrong with the code? "D.W. Warlock" wrote:
pmud wrote:
Hi,
I need to display columns in a data grid based on 7 different queries. Now I have 32 questions:
1. Is it possble to have 1 single data adapter with 7 queries & 1 data set or do I need to have a separate data adapter & a separate data set for each select query? If thats possible then how?
Yes, you can have 1 single adapter with 7 different queries and 1 data set. It all depends on how your stored procedure is written. If there are 7 select statements or unions or whatever, you will get back 7 tables in one stored procedure call that you can then populate into a data set using the data adapter.
2. I have the following code which allows the user to enter an order number & click the view button which should show all information for that order...But the data gris is not showing the infomation, it is showing the only the column headings... I am using only 1 data grid for all the queries... Everytime a different view link (related to a different criteria) is clicked , I change the DataSource , DataKeyField & DataMember for the grid which points to a separate data set.
Code ::
private void LinkButton1_Click(object sender, System.EventArgs e) { sqlDataAdapter1.Fill(dsAllAO1); DataGrid1.DataBind(); }
private void lnkByOrder_Click(object sender, System.EventArgs e) { sqlSelectCommand2.Parameters["@o"].Value=txtOrder.Text;
// Different data set sqlDataAdapter2.Fill(dsByOrder1); DataGrid1.DataSource= dsByOrder1; DataGrid1.DataMember="INVOICES"; DataGrid1.DataKeyField= "ORDER_NO"; DataGrid1.AutoGenerateColumns=true; DataGrid1.DataBind(); }
private void lnkByName_Click(object sender, System.EventArgs e) { sqlSelectCommand2.Parameters["@n"].Value=txtName.Text;
// Different data set sqlDataAdapter2.Fill(dsByName1); DataGrid1.DataSource= dsByName1; DataGrid1.DataMember="INVOICES"; DataGrid1.DataKeyField= "ORDER_NO"; DataGrid1.AutoGenerateColumns=true; DataGrid1.DataBind(); }
Is smthg wrong with this code? Will the data grid not work if I bound it to a different data set on different link button clicks?
Your code above should run fine, but here is something a little leaner and easier to debug:
<code> private void BindData(string sqlQuery, string paramName, object paramValue) { DataTable queryTable = new DataTable(); SqlDataAdapter sda = new SqlDataAdapter(sqlQuery, connection); sda.SelectCommand.CommandType = CommandType.StoredProcedure; if(paramName != null && paramValue != null) { sda.SelectCommand.Paramaters.Add(paramName, paramValue); } sda.Fill(queryTable); DataGrid1.DataSource = queryTable; DataGrid1.DataKeyField = "ORDER_NO"; DataGrid1.AutoGenerateColumns=true; DataGrid1.DataBind(); } </code>
Then, elsewhere in your code, all you would have to do to populate your datagrid is to just call
private void lnkByName_Click(object sender, System.EventArgs e) { // sqlSelectCommand2.Parameters["@n"].Value=txtName.Text; // // Different data set // sqlDataAdapter2.Fill(dsByName1); // DataGrid1.DataSource= dsByName1; // DataGrid1.DataMember="INVOICES"; // DataGrid1.DataKeyField= "ORDER_NO"; // DataGrid1.AutoGenerateColumns=true; // DataGrid1.DataBind();
//Replace above with: BindData("<stored proc name>", "@n", txtName.Text); }
Thanks
hth, ~d
Hi ,
I hope you are well now.Thanks for the answer ... Is there a way to sort the
data grid using the following code...coz here i have not used a data set but
a data table for binding to the data grid...I searched many articles but all
were for binding to the dat set using a data vierw only & more over I am
BINDING THE GRID on DIFFERENT LINK BUTTON CLICKS to ONE DATA TABLE WHICH
CONTAINS DIFFERENT VALUES BASED ON DIFFERENT STORED PROCEDURES....
MY code :
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
private void BindData(string sqlQuery, string paramName, object paramValue)
{
DataTable queryTable = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter(sqlQuery, sqlConnection1);
sda.SelectCommand.CommandType = CommandType.StoredProcedure;
if(paramName != null && paramValue != null)
{
sda.SelectCommand.Parameters.Add(paramName, paramValue);
}
sda.Fill(queryTable);
DataGrid1.DataSource = queryTable;
DataGrid1.DataKeyField = "ORDER_NO";
DataGrid1.AutoGenerateColumns=true;
DataGrid1.DataBind();
}
private void BindData(string sqlQuery, string paramName, object
paramValue,string paramName1, object paramValue1)
{
DataTable queryTable = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter(sqlQuery, sqlConnection1);
sda.SelectCommand.CommandType = CommandType.StoredProcedure;
if(paramName != null && paramValue != null && paramName1 != null &&
paramValue1 != null)
{
sda.SelectCommand.Parameters.Add(paramName, paramValue);
sda.SelectCommand.Parameters.Add(paramName1,paramV alue1);
}
sda.Fill(queryTable);
DataGrid1.DataSource = queryTable;
DataGrid1.DataKeyField = "ORDER_NO";
DataGrid1.AutoGenerateColumns=true;
DataGrid1.DataBind();
}
private void LinkButton1_Click(object sender, System.EventArgs e)
{
BindData("dbo.usp_MasterBrowser_ViewAll",null,null );
}
private void DataGrid1_SortCommand(object source,
System.Web.UI.WebControls.DataGridSortCommandEvent Args e)
{
}
private void lnkByOrder_Click(object sender, System.EventArgs e)
{
BindData("dbo.usp_Order", "@OrderNo", int.Parse(txtOrder.Text));
}
private void lnkByDate_Click(object sender, System.EventArgs e)
{
BindData("dbo.usp_MasterBrowser_Date","@StartDate" ,
System.DateTime.Parse(txtStartDate.Text),"@EndDate ",System.DateTime.Parse(txtEndDate.Text));
}
private void lnkByStatus_Click(object sender, System.EventArgs e)
{
BindData("dbo.usp_MasterBrowser_Status","@Status", ddlStatus.SelectedValue);
}
How can sorting be done in this grid? Is it even possible?
"D0tN3t C0d3r" wrote: Hi pmud,
Sorry about the delay in getting back to you, I was out sick.
Anyhow, when you call "BindData("dob.usp_Order", "@OrderNo", int.Parse(txtOrder.Text));" drop the dbo. in the stored procedure name. For some reason that I have yet to find out, SqlServer/MSDE has issues when using owner.spname conventions.
HTH, ~d
pmud wrote: Hi D.W. Warlock,
I created a stored procedure which works fine when i run it from the server explorer.
Stored Procedure Code:: CREATE PROCEDURE dbo.usp_Order (@OrderNo int) AS select * from IRUS_INVOICES where ORDER_NO = @OrderNo GO
& then I used the followng code... private void BindData(string sqlQuery, string paramName, object paramValue) { DataTable queryTable = new DataTable(); SqlDataAdapter sda = new SqlDataAdapter(sqlQuery, sqlConnection1); sda.SelectCommand.CommandType = CommandType.StoredProcedure; if(paramName != null && paramValue != null) { //sda.SelectCommand.Paramaters.Add(paramName, paramValue); sda.SelectCommand.Parameters.Add(paramName, paramValue); } sda.Fill(queryTable); DataGrid1.DataSource = queryTable; DataGrid1.DataKeyField = "ORDER_NO"; DataGrid1.AutoGenerateColumns=true; DataGrid1.DataBind(); }
private void lnkByOrder_Click(object sender, System.EventArgs e) { BindData("dbo.usp_Order", "@OrderNo", int.Parse(txtOrder.Text));
}
But when I click the view link , the data grid doesnt show up the records ... What is wrong with the code? "D.W. Warlock" wrote:
pmud wrote:
Hi,
I need to display columns in a data grid based on 7 different queries. Now I have 32 questions:
1. Is it possble to have 1 single data adapter with 7 queries & 1 data set or do I need to have a separate data adapter & a separate data set for each select query? If thats possible then how?
Yes, you can have 1 single adapter with 7 different queries and 1 data set. It all depends on how your stored procedure is written. If there are 7 select statements or unions or whatever, you will get back 7 tables in one stored procedure call that you can then populate into a data set using the data adapter.
2. I have the following code which allows the user to enter an order number & click the view button which should show all information for that order...But the data gris is not showing the infomation, it is showing the only the column headings... I am using only 1 data grid for all the queries... Everytime a different view link (related to a different criteria) is clicked , I change the DataSource , DataKeyField & DataMember for the grid which points to a separate data set.
Code ::
private void LinkButton1_Click(object sender, System.EventArgs e) { sqlDataAdapter1.Fill(dsAllAO1); DataGrid1.DataBind(); }
private void lnkByOrder_Click(object sender, System.EventArgs e) { sqlSelectCommand2.Parameters["@o"].Value=txtOrder.Text;
// Different data set sqlDataAdapter2.Fill(dsByOrder1); DataGrid1.DataSource= dsByOrder1; DataGrid1.DataMember="INVOICES"; DataGrid1.DataKeyField= "ORDER_NO"; DataGrid1.AutoGenerateColumns=true; DataGrid1.DataBind(); }
private void lnkByName_Click(object sender, System.EventArgs e) { sqlSelectCommand2.Parameters["@n"].Value=txtName.Text;
// Different data set sqlDataAdapter2.Fill(dsByName1); DataGrid1.DataSource= dsByName1; DataGrid1.DataMember="INVOICES"; DataGrid1.DataKeyField= "ORDER_NO"; DataGrid1.AutoGenerateColumns=true; DataGrid1.DataBind(); }
Is smthg wrong with this code? Will the data grid not work if I bound it to a different data set on different link button clicks?
Your code above should run fine, but here is something a little leaner and easier to debug:
<code> private void BindData(string sqlQuery, string paramName, object paramValue) { DataTable queryTable = new DataTable(); SqlDataAdapter sda = new SqlDataAdapter(sqlQuery, connection); sda.SelectCommand.CommandType = CommandType.StoredProcedure; if(paramName != null && paramValue != null) { sda.SelectCommand.Paramaters.Add(paramName, paramValue); } sda.Fill(queryTable); DataGrid1.DataSource = queryTable; DataGrid1.DataKeyField = "ORDER_NO"; DataGrid1.AutoGenerateColumns=true; DataGrid1.DataBind(); } </code>
Then, elsewhere in your code, all you would have to do to populate your datagrid is to just call
private void lnkByName_Click(object sender, System.EventArgs e) { // sqlSelectCommand2.Parameters["@n"].Value=txtName.Text; // // Different data set // sqlDataAdapter2.Fill(dsByName1); // DataGrid1.DataSource= dsByName1; // DataGrid1.DataMember="INVOICES"; // DataGrid1.DataKeyField= "ORDER_NO"; // DataGrid1.AutoGenerateColumns=true; // DataGrid1.DataBind();
//Replace above with: BindData("<stored proc name>", "@n", txtName.Text); }
Thanks
hth, ~d This discussion thread is closed Replies have been disabled for this discussion. Similar topics
2 posts
views
Thread by Jordan O'Hare |
last post: by
|
1 post
views
Thread by Eagle |
last post: by
|
1 post
views
Thread by Jim |
last post: by
|
5 posts
views
Thread by pmud |
last post: by
|
6 posts
views
Thread by Mike Wilson |
last post: by
|
3 posts
views
Thread by Scottie_do |
last post: by
|
5 posts
views
Thread by Kent Boogaart |
last post: by
|
5 posts
views
Thread by Brian P. Hammer |
last post: by
|
6 posts
views
Thread by =?Utf-8?B?bXIgcGVhbnV0?= |
last post: by
| | | | | | | | | | |