2013-07-31 2 views
0

링크 버튼이있는 격자보기가 있습니다. 클릭 할 때, 나는 어떤 작업을 수행하고 싶었고 클릭 된 링크 버튼을 보이지 않게해야합니다. 보이지 않게 만드는 방법?클릭하면 격자보기에서 링크 단추를 보이지 않게 만드는 방법?

내 코드 :

<asp:TemplateField ShowHeader="true" HeaderText="Theory"> 
     <ItemTemplate> 
      <asp:LinkButton ID="lb_theory" runat="server" CausesValidation="false" CommandArgument='<%#Eval("student_id")%>' OnClientClick="this.disabled = true; " CommandName="theory_remove" Text="Remove" 
command = "lnk_Click" ></asp:LinkButton> 
     </ItemTemplate> 
     </asp:TemplateField> 
      <asp:TemplateField ShowHeader="true" HeaderText="Practical"> 
       <ItemTemplate> 
         <asp:LinkButton ID="lb_practical" runat="server" CausesValidation="false" 
           CommandArgument='<%#Eval("student_id")%>' CommandName="practical_remove" Text="Remove"></asp:LinkButton> 
       </ItemTemplate> 
     </asp:TemplateField> 

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) 
{ 
    if (e.CommandName == "theory_remove") 
    { 
     string st_id = Convert.ToString(e.CommandArgument.ToString()); 
     string t_id = (string)Session["test"]; 
     SqlConnection con = obj.getcon(); 
     con.Open(); 
     string theory_state = "0"; 
     SqlCommand cmd = new SqlCommand("update student_vs_testsession_details set theory='" + theory_state+ "' WHERE student_id='" + st_id + "' and testsession_id='" + t_id + "'", con); 
     int temp = cmd.ExecuteNonQuery(); 
    } 
} 
+0

당신이 내 코드를 보았는가이 방법을 시도? –

답변

0

protected void gridview__RowCommand(object sender, GridViewRowEventArgs e) 
{ 


     GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer); 
     LinkButton lnkbtn = (LinkButton)row.FindControl(”lnkbtnActionNames”); 
     lnkbtn .Visible = false; 


} 
+0

RowDataBound는 gridview로드시에만 작동합니다. – ARATHY

+0

GridView1_RowCommand 이벤트로 시도하십시오. – Janki

+0

e.Row.RowType이 (가) rowcommand 이벤트 아래에 있지 않습니다. – ARATHY

0

내가 개인적으로 Knockout JS 또는 jQuery 그냥 숨어과 HTML 요소를 조작하는 모든 내 클라이언트 측 기능을 관리하는 데 사용하는 것입니다.

+0

jquery는 무엇이 될까요? @ Cubicle.Jockey – ARATHY

+0

왜 mootools, signalr, greasemonkey 및 각도도 좋습니까? –

0

당신의 GridView1_RowCommand 이벤트 것을 숨기기 위해 자바 스크립트

LinkButton mybutton = (LinkButton)sender; 
    mybutton.Visible = false; 
+0

"형식 'System.Web.UI.WebControls.GridView'의 개체를 'System.Web.UI.WebControls.LinkButton'을 입력 할 수 없습니다."라는 오류가 표시됩니다. @ TheProvost – ARATHY

0

사용이를 추가합니다. onclientclick 이벤트를 추가하고 JavaScript를 숨기려면 코드를 작성하십시오. 첫 번째 클라이언트 코드가 실행되고 서버 측이 실행됩니다. 그래서 버튼은 그때 숨어있을 것입니다.

+0

도와주세요 제게 보여 주시겠습니까? @JSHunjan – ARATHY

관련 문제