Monday, 5 January 2015

Link Button operation by(Akram)

Labels And TextBoxex
<table>
<tr>

</tr>
<tr>
<td style="width:102px" class="label_styleRow">Category Name</td>
<td style="width:130px" class="tdtextbox_style">
    <asp:TextBox ID="txtCtName" runat="server" ToolTip="Branch Name"
        CssClass="textbox_char"></asp:TextBox>
    </td>
<td style="width:102px" class="label_style"> </td>
<td style="width:130px" class="label_style"></td>
<td style="width:500px" class="label_style"></td>

</tr>
<tr>

<td class="tdtextbox_style" colspan="5" bgcolor="#99CCFF"></td>

</tr>
<td>
</table>


Grid View
<asp:Panel ID="panelg" runat="server" Width="241px" Height="176px" ScrollBars="Both" Visible="false">
    <asp:GridView ID="gvCategory" runat="server" AutoGenerateColumns="False"
        onrowcommand="gvCategory_RowCommand" BackColor="White"
        BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="4"
      
       EnableModelValidation="True" ForeColor="Black" GridLines="Both"
        >
        <Columns>
          <asp:TemplateField HeaderStyle-CssClass="label_styleRow" HeaderText="Category ID">   
            <ItemTemplate>
             <asp:LinkButton ID="lnkID" runat="server" CommandName="Find"
                    CssClass="label_style" ForeColor="Black" Text='<%# Eval("CT_ID") %>'></asp:LinkButton>
            </ItemTemplate>      
              <HeaderStyle CssClass="label_styleRow" />
            </asp:TemplateField>            
            <asp:TemplateField HeaderStyle-CssClass="label_styleRow" HeaderText="Category NAME">              
                <ItemTemplate>
                    <asp:Label ID="lbl_name" runat="server" CssClass="label_style" Text='<%# Eval("CT_NM") %>'></asp:Label>
                </ItemTemplate>
                <HeaderStyle CssClass="label_styleRow" />
            </asp:TemplateField>
                              
        </Columns>
       <FooterStyle BackColor="#CCCC99" ForeColor="Black" />
        <HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" />
        <SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
        <%--<SortedAscendingCellStyle BackColor="#F1F1F1" />
       
       
        --%>
    </asp:GridView>
    </asp:Panel>


Code (C#)  After Display All Data in Grid view
>select Gridview >properties>Fire Row Command
write on ..
  LinkButton lnk = (LinkButton)e.CommandSource;
            GridViewRow gr = (GridViewRow)lnk.NamingContainer;
            Label Ctname = (Label)gr.FindControl("lbl_name");
            txtCatID.Text = lnk.Text;
            txtCtName.Text = Ctname.Text;

No comments:

Post a Comment