.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Windows Application >> Post New QuestionBookmark and Share Subscribe to Forum

Windows Application-datagridview

Posted By: Jayakumar     Posted Date: March 01, 2010    Points:2   Category :Windows Application
hi,

i am rendering a table thro the datagridview(3.5,c#)

the table has following columns (sno,name,age), in this name is link column.

sno name age
1 a 23
2 b 24
3 c 22

when i click the name(a) column, the corresponding record(sno,name,age) has to be displayed in separate textboxes.

how it can be done..

Responses
Author: Syed Shakeer Hussain          Accepted Answer   
Posted Date: March 01, 2010     Points: 10   

Hi
use the following code
Private void dataGridView1_CellContentClick_1(objectsender,DataGridViewCellEventArgs e)
{
i = dataGridView1.SelectedCells[1].RowIndex;
textBox1.Text = dataGridView1.Rows[i].Cells[0].Value.ToString();
textBox2.Text = dataGridView1.Rows[i].Cells[1].Value.ToString();
textBox3.Text = dataGridView1.Rows[i].Cells[2].Value.ToString();
}

for more information check the below link
http://www.dotnetspark.com/kb/608-how-to-get-values-slected-cell-row-datagridviewwindows.aspx

Author: Naresh             
Posted Date: March 02, 2010     Points: 5   

Hi JayaKumar,

You can try the code in DataGrid Selected Index Change:


protected void DataGrid1_SelectedIndexChanged(object sender, EventArgs e)
{
Textbox1.text = DataGrid1.SelectedItem.Cells[1].Text;
}



thanks

Thanks
Naresh


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend