hey guys, its me again lol.
anyway. my interface looks like this ... thats a sample interface that bugging me out. as i have 2 options.
option #1. enable the add button(button field) to get the value of the unit or serialnumber and insert it to a container table.
option #2. use select and the "add product to invoice" button (found below).
im not really that familiar with tinkering with the button field so im leaning more towards option #2. problem is im stuck with this property: gridview1.selectedrow.
i dont know whats next, is there a method that i can use to extract the value of a specified column?
thanks
Loading
Kirtan PatelPosted Nov 24, 2009, 6:51 AM
Seems Problem is With PageLoad Method if you are filling GridView Programatically then PageLoad Event Should be Like Below . label may loose value because of PostBack so do code like below if you are filling GridView Programatically :)
PageLoad()
{
if(!IsPostBack)
{
//your Code to Fill GridView
}
}
then change the Value Of Label in
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
Label1.Text = GridView1.Rows[0].Cells[0].Text;
}
if still facing problem then paste whole page Code Behind Code Here or Just Mail Me at [email protected] because alignment not properly shown here on forum :)
Mark UyPosted Nov 24, 2009, 8:24 AM
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
Label1.Text = GridView1.SelectedRow.Cells[1].Text;
}
thanks for the help anyways. be back again in the future
Mark UyPosted Nov 24, 2009, 7:16 AM
{
if (!IsPostBack)
{
SqlConnection conInvoice = new SqlConnection
(@"Data Source=.\SQLEXPRESS;AttachDbFileName=|DataDirectory|\TRANE.mdf;Integrated Security=True;User Instance=True");
conInvoice.Open();
SqlDataSource1.SelectCommand = "SELECT * FROM [Unit] WHERE ([UnitDesc] LIKE '%' + @UnitDesc + '%')";
SqlDataSource1.DataBind();
}
}
protected void btnLookup_Click(object sender, EventArgs e)
{
SqlConnection conInvoice = new SqlConnection
(@"Data Source=.\SQLEXPRESS;AttachDbFileName=|DataDirectory|\TRANE.mdf;Integrated Security=True;User Instance=True");
conInvoice.Open();
SqlDataSource1.SelectCommand = "SELECT * FROM [Unit] WHERE ([UnitDesc] LIKE '%' + @UnitDesc + '%')";
SqlDataSource1.DataBind();
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
Label1.Text = GridView1.Rows[0].Cells[0].Text;
}
}
sadly it didnt work. the label becomes blank. any more ideas?
Mark UyPosted Nov 24, 2009, 6:23 AM
any further help?
Mark UyPosted Nov 24, 2009, 6:10 AM
RujutaPosted Nov 24, 2009, 2:27 AM
Here id will contain the value of the specific cell.
I feel its quite easy this way.
Hope it'll help you...