Click here to Skip to main content
15,902,635 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
protected void rptGroupMember_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            string groupID = "";
            switch (e.CommandName)
            {
                case "Click":
                    {
                        PopulateUserList(WorldEvolveModel.TherapistLevel.All.ToString());
                        HiddenField hid = ((LinkButton)e.CommandSource).FindControl("hfMessageGroupID") as HiddenField;
//here i am getting the id.
                        groupID = hid.Value.ToString();
                    }
                    break;
                default:
                    {
                        txtSearchMember.Text = "Can't Get Groups...";
                    }
                    break;
            }
        }

        //Method for get the selected member from popup and save them in database
        protected void SaveSelectedGroupMember()
        {
            MessageGroupMemberDAL dal = new MessageGroupMemberDAL();
            MessageGroupMemberModel model = new MessageGroupMemberModel();
            MessageGroupDAL dalMG = new MessageGroupDAL();

            string[] str = hfSelectedMembeID.Value.Split(',');

            for (int i = 0; i < str.Length; i++)
            {
                //Get_UserProfiler(HttpContext.Current.User.Identity.Name);
                model.GroupMemberID = 0;

//in first function i commented code.that i m getting id here.i want to use that is here in place of 3.
                model.MessageGroupID = 3;
                model.MemberID = Convert.ToInt32(str[i]);
                model.MemberType = "test";

                dal.InsertUpdate_MessageGroupMembers(model);
            }
        }


how can i do this...

plz help me...
Posted

You can use ViewState like this:
1. Assign groupid in rptGroupMember_ItemCommand function
ViewState["groupID"] = hid.Value.ToString();

2. use this in SaveSelectedGroupMember function
model.GroupMemberID = ViewState["groupID"] ;// cast here accordingly
 
Share this answer
 
Dear Friend.,

just try the following steps any one..

1.you just declare that string groupID is private an outside of function. or
2.use view state or
3.create one new hidden field control in your form. and assign group id value to new hidden field value. and use new hidden field value to in your function..

I hope this information helpful to you.,

Thanks and regards

Angappan.S
 
Share this answer
 
In this class you can have a global variable called _hid.
C#
int _hid = 0;

Its better to initialize it to 0 in the constructor or as you declare it globally.

Then as you are getting the hid in the 1st method just save it to _hid and then use it later.
C#
_hid = hid;


Inside the second method:
C#
<pre lang="cs">for (int i = 0; i < str.Length; i++)
            {
                //Get_UserProfiler(HttpContext.Current.User.Identity.Name);
                model.GroupMemberID = 0;
               
                model.MessageGroupID = _hid;
                model.MemberID = Convert.ToInt32(str[i]);
                model.MemberType = "test";

                dal.InsertUpdate_MessageGroupMembers(model);
            }


In the second method maybe have a if statement to check if _hid is 0 and do something with the value.
 
Share this answer
 

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