0

I have button and GridView at UserControl. When I press button.It will perform at PageLoad function. But when I click select in GridView.It can't work same button at PageLoad.

 if (!IsPostBack){}             
 else{
                    string str_btn = null;
                    if (Request.Form.Keys[Request.Form.Keys.Count - 1]!=null)
                        str_btn=Request.Form.Keys[Request.Form.Keys.Count - 1].ToString();
                    if(!string.IsNullOrEmpty(str_btn))
                       handleClick(str_btn);
                    else
                        Response.Redirect("../Ipservice/IpserviceDevices.aspx?btn=ipservice", false);
                }

Do you have any solution for resolved this issues.

I wondered if you share your knowledge

IpInterfaceUC UserControl

<div id="dvChannel" runat="server">
        <asp:GridView ID="gvChannelUC" 
            OnRowCommand="gvChannelUC_RowCommand"
            OnSelectedIndexChanged="gvChannel_SelectedIndexChanged"
        />
</div>

IPServices page CodeBehind

if (!IsPostBack){
}else
{    
 string str_btn = Request.Form.Keys[Request.Form.Keys.Count - 1].ToString();
 handleClick(str_btn);
}

Question

It always show str_btn is null.If I click Button,It'll show button's id.But when I click Select at GridView,It show str_btn is null.It should be show GridView's id when we click select.

Thanks for any explain.

Brian
  • 163
  • 2
  • 18
  • Where is the GridView markup? There is no reference to GridView in your question? – codingbiz Jan 09 '13 at 09:26
  • GridView is in UserControl.I click gridview event on aspx page. – Brian Jan 09 '13 at 09:44
  • I edit my description issues.I wondered if you share me any your solution.Thanks – Brian Jan 09 '13 at 10:17
  • Your GridView does not have a select button. At least your GridView should have `AutoGenerateSelectButton="true"`. And why are you not using the normal event handlers like Button_Click, GridView_RowCommand? – codingbiz Jan 09 '13 at 10:42
  • Yes,I did it.But it didn't work.My description just bref code,It just have main code.I hide some code in this description – Brian Jan 09 '13 at 10:44
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/22446/discussion-between-binh-tieu-and-codingbiz) – Brian Jan 09 '13 at 10:48
  • Hi brother,Because my project need add more than 1 Devices – Brian Jan 10 '13 at 07:56
  • Devices is same as UserControl So that,I need design more than a Devices It'll dynamic Devices – Brian Jan 10 '13 at 07:56
  • Are u there?May we discuss something? – Brian Jan 10 '13 at 10:33

0 Answers0