TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ashok Kumar
NA
38
45.9k
selecting record from listview getting error while showing in textboxes
Aug 3 2012 2:31 AM
Hi friends,
i am working a small application which should display data in textbox when selected the listview , the problem i am getting when i apply leaves for same employee code with differnt leave type and when i am selecting the recorded added listview to show data in textboxes it getting error and displaying the data but when i close the application and open and again i select the recorded from listview the error will not come for the first time applying and selected record for first time only it will come. please some one help me.
the error is
it will show '
fromdate
' in a small box, first time when i select listview index record, when i added leaves for same employee code different leave type
when i use break point listapproval.Items[i].Selected == true it is showin false and after that it will show
the code is
private void listapproval_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
groupBox3.Visible = true;
txtEmpCode.Enabled = false;
btnSave.Enabled = false;
btnDelete.Enabled = true;
// btnDelete.Enabled = true;
string empcode = "";
string empname = "";
string leavetype = "";
string fromdate = "";
string todate = "";
string description = "";
string status = "";
for (int i = 0; i < listapproval.Items.Count; i++)
{
if (listapproval.Items[i].Selected == true)
{
empcode = listapproval.Items[i].SubItems[0].Text;
empname = listapproval.Items[i].SubItems[1].Text;
leavetype = listapproval.Items[i].SubItems[2].Text;
fromdate = listapproval.Items[i].SubItems[3].Text;
todate = listapproval.Items[i].SubItems[4].Text;
status = listapproval.Items[i].SubItems[5].Text;
string q1="select LeaveCode From LeaveMaster Where LeaveName='"+leavetype+"'" ;
DBCom.getData(q1);
if(DBCom.rdr.HasRows)
{
while(DBCom.rdr.Read())
{
lc =DBCom.rdr["LeaveCode"].ToString();
}
}
Reply
Answers (
2
)
error selecting listview value and displaying in textboxes
how to take data from one form to another