Click here to Skip to main content
15,918,050 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello guys,

Is there any way to bind values to any perticular column in grid like we can do in dropdown?
<br />
dropdown1.DataValueField = data source column


I have a gridm, but I have to hide the ID Column of that grid so when I am saving the records on save button click, I am not getting the ID's, as I want to save the new order on the basis of ID's in the database.

Is there any way I can get the ID's keeping the ID column visible="false"?

If I make it visible ii starts getting the ID's again.

Thanks
Posted
Updated 9-Apr-11 3:09am
v2
Comments
Dalek Dave 9-Apr-11 9:09am    
Edited for Grammar, Syntax and Readability.

1 solution

This is the code snippet, you can enhance and use as you require. Just handle the row-editing event in code-behind.
asp:GridView ID="gvwTest" runat="server" CssClass="display" AutoGenerateColumns="False" DataKeyNames="id" OnRowEditing="gvwTest_RowEditing" Width="100%">
    <columns>
        <asp:boundfield datafield="code" headertext="Code" itemstyle-width="75px" xmlns:asp="#unknown" />
        <asp:boundfield datafield="name" headertext="Name" xmlns:asp="#unknown" />
        <asp:commandfield showeditbutton="True" itemstyle-width="50px" xmlns:asp="#unknown" />
    </columns>
 
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