when particular row is selected then all values have to be
displayed in rich text box(which is user control)
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
yadagiri uppariPosted Jun 11, 2013, 9:07 AM
working....My problem is to get all values of row which is selected
in list view in asp.net
Sharad GuptaPosted Jun 11, 2013, 8:33 AM
HI yadagiri uppari
Try this one......
using System;
using System.Data;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApplication12
{
public partial class Form1 : Form
{
SqlDataAdapter da;
DataTable dt;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
listView1.Items.Clear();
da = new SqlDataAdapter("select * from emp", "Data Source=MCNDESKTOP07;Initial Catalog=manish;User ID=sa;Password=***********");
dt = new DataTable();
da.Fill(dt);
foreach (DataRow dr in dt.Rows)
{
ListViewItem itm = new ListViewItem(dr["empId"].ToString());
itm.SubItems.Add(dr["empName"].ToString());
listView1.Items.Add(itm);
}
}
private void button2_Click(object sender, EventArgs e)
{
//for displaying in to textbox
if (listView1.SelectedItems.Count > 0)
{
richTextBox1.Text = listView1.SelectedItems[0].SubItems[0].Text +" "+ listView1.SelectedItems[0].SubItems[1].Text;
}
}
}
}