datagrid editing

Results 1 to 2 of 2

Thread: datagrid editing

  1. #1
    Join Date
    Dec 1969

    Default datagrid editing

    Am learnign and got this sample of datagrid editing from website. <BR>When i click on edit button of datagrid instead of showing text boxes to edit the datagrid dissappears. <BR><BR>can this be becoz of postback issues ?<BR><BR>Heres the code<BR><BR><BR>The datagrid is binding in the submit sub.<BR><BR>sub submit(obj as object, e as eventargs)<BR>&#039;&#039; data connection sql query retrieve and binding to datagrid not using pagepostback<BR>end sub <BR><BR>sub dguserdetails_edit(obj as object, e as datagridcommandeventargs)<BR> dguserdetails.edititemindex=e.item.itemindex<BR> dguserdetails.databind()<BR>end sub<BR><BR>sub dguserdetails_update(obj as object, e as datagridcommandeventargs)<BR>end sub<BR><BR>sub dguserdetails_cancel(obj as object, e as datagridcommandeventargs)<BR> dguserdetails.edititemindex=-1<BR> dguserdetails.databind()<BR>end sub<BR>&#060;asp:datagrid id="dguserdetails" autogeneratecolumns=false <BR>oneditcommand=dguserdetails_edit<BR>oncancelco mmand=dguserdetails_cancel<BR>onupdatecommand=dgus erdetails_update<BR>runat=server&#062;<BR>&#060;co lumns&#062;<BR>&#060;asp:boundcolumn datafield=userid headertext=userid /&#062;<BR>&#060;asp:boundcolumn datafield=logonname headertext=logonname /&#062;<BR>&#060;asp:boundcolumn datafield=passwd headertext=passwd /&#062;<BR>&#060;asp:boundcolumn datafield=firstname headertext=firstname /&#062; <BR>&#060;asp:editcommandcolumn edittext=edit canceltext=cancel updatetext=update headertext=edit /&#062;<BR>&#060;/columns&#062;<BR>&#060;/asp:datagrid&#062;<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: datagrid editing

    When you create a bound datagrid, you need to bind it every time the pages loads:<BR><BR>[code language="c#"]<BR>public void Page_Load(object sender, EventArgs e)<BR>{<BR> BindDataGrid();<BR>}<BR><BR>private void BindDataGrid()<BR>{<BR> // Create DB Connection<BR> // Execute some SQL SELECT Statement<BR> // Fill in a DataTable, table, with the retrieved data<BR> <BR> // Set the DataSource of your DataGrid<BR> myGrid.DataSource = new DataView(table);<BR> <BR> // Bind the DataGrid<BR> myGrid.DataBind();<BR>}<BR>[/code]<BR><BR>Now, if you don&#039;t want the datagrid to be display unless the user clicks the Submit button, you should add code to the Page_Load() method to hide the datagrid.<BR><BR>Then in the Submit_Click() method, you can set myGrid.Visible = true;<BR><BR>Hope this helps<BR>-Steve<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts