Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear All Experts,

In my grid view five columns only two columns or editable mode remaining three colums non editable mode (asp.net,CSharp) but button is taken outside the grid view.

Thank u for your valuable replay
Posted

make rows which you want to edit as:
datagridview1.Rows[row].Cells["ID"].EditedFormattedValue = true;
to not edit make row as :
datagridview1.Rows[row].Cells["ID"].EditedFormattedValue = false;
 
Share this answer
 
v2
Subbu1999 wrote:
In my grid view five columns only two columns or editable mode remaining three colums non editable mode
Make the columns Readonly.
The ProductID column is non-editable due to the ReadOnly="True" setting in the associated BoundField.
XML
<asp:GridView ID="GridView1" Runat="server"
    DataSourceID="productDataSource" DataKeyNames="ProductID"
    AutoGenerateColumns="False" AllowPaging="True"
    BorderWidth="1px" BackColor="White"
    CellPadding="4" BorderStyle="None" BorderColor="#3366CC">
    <FooterStyle ForeColor="#003399"
       BackColor="#99CCCC"></FooterStyle>
    <PagerStyle ForeColor="#003399" HorizontalAlign="Left"
       BackColor="#99CCCC"></PagerStyle>
    <HeaderStyle ForeColor="#CCCCFF" Font-Bold="True"
       BackColor="#003399"></HeaderStyle>
    <Columns>
        <asp:CommandField ShowEditButton="True"></asp:CommandField>
        <asp:BoundField ReadOnly="True" HeaderText="ProductID"
            InsertVisible="False" DataField="ProductID"
            SortExpression="ProductID"></asp:BoundField>
        <asp:BoundField HeaderText="Product"
            DataField="ProductName"
            SortExpression="ProductName"></asp:BoundField>
        <asp:BoundField HeaderText="Unit Price"
            DataField="UnitPrice" SortExpression="UnitPrice">
            <ItemStyle HorizontalAlign="Right"></ItemStyle>
        </asp:BoundField>
        <asp:BoundField HeaderText="Units In Stock"
           DataField="UnitsInStock" SortExpression="UnitsInStock">
            <ItemStyle HorizontalAlign="Right"></ItemStyle>
        </asp:BoundField>
    </Columns>
    <SelectedRowStyle ForeColor="#CCFF99" Font-Bold="True"
        BackColor="#009999"></SelectedRowStyle>
    <RowStyle ForeColor="#003399" BackColor="White"></RowStyle>
</asp:GridView>
 
Share this answer
 
Comments
2011999 25-Nov-11 11:31am    
this code also inside gridbutton i need outside the gridview button

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