By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,401 Members | 814 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,401 IT Pros & Developers. It's quick & easy.

Editable data grid

P: 6
Hi,

I am trying to implement an editable datagrid in .net 2005

This is how my grid is defined:

<asp:DataGrid runat="server" id="dgUser"
Font-Name="Verdana" Font-Size="9pt" CellPadding="5"
AlternatingItemStyle-BackColor="#dddddd"
AutoGenerateColumns="False" DataKeyField="UserId"
OnEditCommand="dgUser_EditRow">

<HeaderStyle BackColor="Navy" ForeColor="White" Font-Size="13pt"
Font-Bold="True" HorizontalAlign="Center" />

<Columns>
<asp:EditCommandColumn ButtonType="LinkButton" HeaderText="Edit"
EditText="Edit" UpdateText="Update" CancelText="Cancel" />
<asp:BoundColumn DataField="UserId" HeaderText="Id" />

<asp:BoundColumn DataField="URole" HeaderText="Role" />
<asp:BoundColumn DataField="Fname" HeaderText="First" />
<asp:BoundColumn DataField="Mname" HeaderText="Middle" />
<asp:BoundColumn DataField="Lname" HeaderText="Last" />
<asp:BoundColumn DataField="StreetAddr" HeaderText="Street" />
<asp:BoundColumn DataField="AptNo" HeaderText="Apt #" />
<asp:BoundColumn DataField="City" HeaderText="City" />
<asp:BoundColumn DataField="State" HeaderText="State" />
<asp:BoundColumn DataField="Zipcode" HeaderText="Zip" />
<asp:BoundColumn DataField="Country" HeaderText="Country" />
<asp:BoundColumn DataField="PhoneNo" HeaderText="Phone #" />
<asp:BoundColumn DataField="EmailId" HeaderText="Email" />
</Columns>

</asp:DataGrid>


And following is the event I am calling on click event of the edit button in grid



protected void dgUser_EditRow(object source, DataGridCommandEventArgs e)
{

dgUser.EditItemIndex = e.Item.ItemIndex;
dgUser.DataBind();
}


somehow its not giving me anything on pressing edit.

Do I have to put any hidden text box controls and make them visible when edit button is clicked?

Can anyone help me on this ?
Apr 20 '07 #1
Share this Question
Share on Google+
1 Reply


P: 6
Thanks to all. Problem solved with gridview control ..lol

Hi,

I am trying to implement an editable datagrid in .net 2005

This is how my grid is defined:

<asp:DataGrid runat="server" id="dgUser"
Font-Name="Verdana" Font-Size="9pt" CellPadding="5"
AlternatingItemStyle-BackColor="#dddddd"
AutoGenerateColumns="False" DataKeyField="UserId"
OnEditCommand="dgUser_EditRow">

<HeaderStyle BackColor="Navy" ForeColor="White" Font-Size="13pt"
Font-Bold="True" HorizontalAlign="Center" />

<Columns>
<asp:EditCommandColumn ButtonType="LinkButton" HeaderText="Edit"
EditText="Edit" UpdateText="Update" CancelText="Cancel" />
<asp:BoundColumn DataField="UserId" HeaderText="Id" />

<asp:BoundColumn DataField="URole" HeaderText="Role" />
<asp:BoundColumn DataField="Fname" HeaderText="First" />
<asp:BoundColumn DataField="Mname" HeaderText="Middle" />
<asp:BoundColumn DataField="Lname" HeaderText="Last" />
<asp:BoundColumn DataField="StreetAddr" HeaderText="Street" />
<asp:BoundColumn DataField="AptNo" HeaderText="Apt #" />
<asp:BoundColumn DataField="City" HeaderText="City" />
<asp:BoundColumn DataField="State" HeaderText="State" />
<asp:BoundColumn DataField="Zipcode" HeaderText="Zip" />
<asp:BoundColumn DataField="Country" HeaderText="Country" />
<asp:BoundColumn DataField="PhoneNo" HeaderText="Phone #" />
<asp:BoundColumn DataField="EmailId" HeaderText="Email" />
</Columns>

</asp:DataGrid>


And following is the event I am calling on click event of the edit button in grid



protected void dgUser_EditRow(object source, DataGridCommandEventArgs e)
{

dgUser.EditItemIndex = e.Item.ItemIndex;
dgUser.DataBind();
}


somehow its not giving me anything on pressing edit.

Do I have to put any hidden text box controls and make them visible when edit button is clicked?

Can anyone help me on this ?
Apr 20 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.