DataGrid question

G

Guest

Hi all

I am tryint to edit a cell in a row of a datagrid web control with no luck, could not find anything on the web in Visual Basic (only C#), anyone has a sample code

Thanks
 
G

Guest

Dear Shammu

You have to bind the items using Container.DataItem as well as have ItemTemplate and EditItemTemplate to achieve this

I will give you the sample for one Edit Item

<Columns><asp:TemplateColumn><HeaderTemplate
First Nam
</HeaderTemplate><ItemTemplate><%# Container.DataItem("FirstName")%></ItemTemplate><EditItemTemplate><asp:TextBox ID="txtFirstName" Text='<%# Container.DataItem("FirstName" )%>' Runat="Server" /><asp:RequiredFieldValidator ControlToValidate="txtFirstName" Display="Dynamic" Text="First Name Cannot be Blank!
Runat="Server" ID="Requiredfieldvalidator1" /></EditItemTemplate></asp:TemplateColumn

give the above code in the html section and the following code in the codebehin

Public Sub dgrd_EditCommand(ByVal sender As Object, ByVal e As DataGridCommandEventArgs
dgrd.EditItemIndex = e.Item.ItemInde
BindData(
End Su

where BindData() is the method which you use to bind the data to the datagrid

make sure when you define the datagrid, specify the edit comman

<asp:datagrid id="dgrd" OnEditCommand="dgrd_EditCommand"

hope it helps

----- Shammu wrote: ----

Hi all

I am tryint to edit a cell in a row of a datagrid web control with no luck, could not find anything on the web in Visual Basic (only C#), anyone has a sample code

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top