Click here to Skip to main content
15,887,262 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
iam using c# code for this. i have 2textbox and one button and a table in my database name as customerMaster. my query is:
when button is clicked the gridview is shown and from that i can select customername and customer id , after the value is selected the gridview shoud not be visible and the sselected values should be seen in textboxes.
till now im able to do is:
made the gridview invisible and only two values are available from the customertable . customername and id.
can anyone tell me how i do the rest?

its urgent need!!

What I have tried:

C#
public partial class gridv : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        GridView1.Visible = false;
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection("Data source = MICKEY\\SQLEXPRESS; Initial Catalog = rr; Integrated Security = True; User Id = k; Password = mickey");
        SqlCommand cmd = new SqlCommand("select customername,customeridno from customerMaster ");
        SqlDataAdapter da = new SqlDataAdapter(cmd.CommandText, con);
        DataSet ds = new DataSet();
        da.Fill(ds);
        GridView1.DataSource = ds;
        GridView1.DataBind();
        GridView1.Visible = true;


    }
}
Posted
Updated 15-Mar-16 21:29pm
v2

Put a button in the gridview that allows the user to select that row, and when they do read the values from the row and put them in your text boxes.

How to: Respond to Button Events in a GridView Control[^]
 
Share this answer
 
Comments
Member 12355460 15-Mar-16 8:31am    
answer not helping :(
F-ES Sitecore 15-Mar-16 8:53am    
We're not here to do your code for you, you haven't posted a problem you've posted your requirements. If you read that link and take time to try\understand it, it will become clear how you use it in your own problem.
Member 12355460 16-Mar-16 3:30am    
did not ask about the code. but if i have an query whr should i seek it.
i generated it all by myself.

C#
protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
       {
           TextBox19.Text = GridView2.SelectedRow.Cells[1].Text;
           TextBox20.Text = GridView2.SelectedRow.Cells[2].Text;

       }

       protected void Button1_Click(object sender, EventArgs e)
       {
           SqlConnection con = new SqlConnection ("Data Source = MICKEY\\SQLEXPRESS; Initial catalog = rr; User Id = k; Password = mickey; integrated security = True");
           //BDataAccess.dataConnect objda = new BDataAccess.dataConnect();
          // SqlConnection con = new SqlConnection(objda);

           SqlCommand cmd = new SqlCommand("select customername , customeridno from customerMaster");
           SqlDataAdapter da = new SqlDataAdapter(cmd.CommandText, con);
           DataSet ds = new DataSet();
           da.Fill(ds);
           GridView2.DataSource = ds;
           GridView2.DataBind();

       }

   }
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900