Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ADO.NET
I am working on three datagrid web applicaion on one web page (ASPX) which share on paramete which is Primarykey I like to insert parameter in textbox which populte three datagrid My parameter is INT datatype and I already wrote 3 store proc which has same serial number. Thank you in advance.
Posted 12-Jul-12 14:34pm
Edited 12-Jul-12 14:43pm
v2
Comments
Wes Aday at 12-Jul-12 21:04pm
   
I am quite sure that someone, somewhere is overjoyed that you have gainful employment. Do you have an actual question or did you just stop by to let us know that you have some work to do?

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
 
find the sample code bellow:
 
<pre lang="c#">
bindGrids(GridView1, txtSerialNumber.Text, "procSample1", "@param");
bindGrids(GridView2, txtSerialNumber.Text, "procSample2", "@param");
bindGrids(GridView3, txtSerialNumber.Text, "procSample3", "@param");
 

 
The method deifnation is:
private void bindGrids(GridView gvControl, string serialNumber, string storedProcedure, string sqlParameterName)
    {
        try
        {
            SqlConnection dbCon = new SqlConnection("Data Source = .; Initial Catalog=ContosoHR; Integrated Security=True");
            SqlCommand dbcmd = new SqlCommand(storedProcedure, dbCon);
            dbcmd.CommandType = CommandType.StoredProcedure;
            SqlParameter param = new SqlParameter(sqlParameterName, serialNumber);
            dbcmd.Parameters.Add(param);
            DataSet dSet = new DataSet();
            SqlDataAdapter dbAdp = new SqlDataAdapter(dbcmd);
            dbAdp.Fill(dSet);
            gvControl.DataSource = dSet;
            gvControl.DataBind();
        }
        catch (Exception ex)
        {
 
        }
    }
 
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 485
1 mhegazy94 460
2 Kornfeld Eliyahu Peter 315
3 Ravi Bhavnani 200
4 Shemeemsha RA 160
0 Sergey Alexandrovich Kryukov 6,890
1 OriginalGriff 6,761
2 CPallini 5,350
3 George Jonsson 3,609
4 Gihan Liyanage 2,797


Advertise | Privacy | Mobile
Web01 | 2.8.140922.1 | Last Updated 13 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100