Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. DataGrid

DataGrid

Scheduled Pinned Locked Moved ASP.NET
question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rahithi
    wrote on last edited by
    #1

    hi all, right now i am trying to work on Datagrid. 1.How do you apply specific formatting to the data inside the cells? and in my gird i am giving option to the user to modify the rows. before updating the data, just i want to check whether the user modified any data?? 2.How do you check whether the row data has been changed? 3.How do you customize the column content inside the datagrid? just we need to make the column as Item template?? or do need to write any code? thanks, Rahi

    If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

    K 1 Reply Last reply
    0
    • R Rahithi

      hi all, right now i am trying to work on Datagrid. 1.How do you apply specific formatting to the data inside the cells? and in my gird i am giving option to the user to modify the rows. before updating the data, just i want to check whether the user modified any data?? 2.How do you check whether the row data has been changed? 3.How do you customize the column content inside the datagrid? just we need to make the column as Item template?? or do need to write any code? thanks, Rahi

      If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

      K Offline
      K Offline
      kiran kumar Intelligroup
      wrote on last edited by
      #2

      Hi Rahi, I am not sure but this will give you some idea! 1.You can apply specific formatting to the data inside the cells using DataGrid rightclick>PropertyBuilder>Formatting>Items 2.You can add a hidden grid column say "Modified" and it's default value is "N".Now in DataGrid1_ItemDataBound you need to add clientside ontextchage eventhandler for desired cells Serverside:- private void DataGrid1_ItemDataBound(object sender,System.Web.UI.WebControls.DataGridItemEventArgs e) { //This code is for assigning userdefined Id's for rows and columns e.Item.ID = "Row" + i++; for(int j=0;j<7;j++) e.Item.Cells[j].ID="Column"+j; //Here you need to pass the rowid e.Item.Cells[j].Attributes.Add("ontextchanged","modif('"+ e.Item.ID + " ')" ); } JavaScript:- function modif(RowId) { //This line will set the value to 'Y' when the row is modified document.getElementById('DataGrid1_'+RowId +'_Modified').innerText="Y" } 3.When you give the provision for editing the rows you can also validate the datagrid. private void Page_Load(object sender, System.EventArgs e) { da.Fill(dataSet11,"employee"); DataGrid1.DataBind(); Button1.Attributes.Add("onclick","return validate()"); } JavaScript:- function validate() { if(document.getElementById('DataGrid1_Row0_Column1').innerText="") alert('Please enter '); //Like this you can set the values to the grid document.getElementById('DataGrid1_Row0_Column1').innerText="kkkk"; alert(document.getElementById('DataGrid1_Row0_Column1').innerText); return false; }

      Kiran Kumar.CH (MCP)

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups