Click here to Skip to main content
15,944,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

how to fetch record in datatable
i done it but i got only one record...when i going to seccond record...its no return value..

DataTable dt = new DataTable();

        string memberid = Session["useridno"].ToString();
        string senderid =  Request.QueryString["Id"].ToString();

        //clsregisterinfo.SenderId = senderid;
        clsregisterinfo.ReceiverId = memberid;

        dt = clsregisterinfo.fetch_friendrequest();
        if (dt.Rows.Count > 0)
            for (int i = 0; i < dt.Rows.Count;i++ )
                if (dt.Rows[i]["Reg_Id"].ToString() == senderid)
                    btninterest.Enabled = false;
                    btninterest.Visible = false;
            btninterest.Enabled = true;
            btninterest.Visible = true;

1 solution

This approach is almost correct.Check if there is data for this item in the second row.

In addition, if you are putting enabled condition once in the loop, this will change everytime the loop runs.
Check if you want this functionality.

if (dt.Rows[i]["Reg_Id"].ToString() == senderid)
    btninterest.Enabled = false;
    btninterest.Visible = false;
Share this answer
Manish Dalwadi 15-Mar-14 0:39am    
my coding is check that
someone send me request or not
if i already a member of someon then i cant see "send interest" button otherwise i can se it

so when i login my account then that time my session id is passed in member id
and someones id geting from request.querystring and pass in senderid variable.
if check that senderid==dt.rows[0]["reg_id".tostring())
btn have to visible=false,

request_id reg_id memberid
----------- ------- ---------
1 8 9
2 8 10
3 10 9
4 11 9
5 12 9

reg_id is a sender

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