title: how to get only first row of datatable with modified specific row value
body: <p>I have query to just summary of total no of jobs running. now I just want some specific result if there is unique rows found like unique category id with assign job then ok with multiple record set. but no category found if is null then just only pass first record from datatable with modified text with 'ALL' as category name. can we achieve this result.</p>
  
  <p>here is my query and some operations I'm doing with them.</p>
  
  <pre><code>string str = "";
              DataTable dt = new DataTable();
              str = "SELECT j.[JobID], p.[Id] As PreparedEmailID,p.[Title] AS 'PreparedEmailName',j.[CreatedOn],j.[CompletedOn],j.CategoryID,j.[SubscriberCount],j.[EmailsSent],c.[CategoryName] As SubscriberCategory,(SELECT TOP 1 [Message] FROM [LoggedMessages] WHERE [JobID] =j.[JobID] ORDER BY [LoggedMessageID] DESC) AS 'LoggedMessage',(SELECT [Name] FROM tbl_User_master u WHERE u.Id =j.UserID) As CreatedBy FROM [Jobs] AS j INNER JOIN [tbl_Email_master] AS p ON p.[Id] = j.[PreparedEmailID] INNER JOIN [tbl_User_master] AS u ON u.[Id]=j.[UserID] INNER JOIN tbl_Categories c ON c.Id = j.CategoryID OR (c.Id IS NOT NULL AND j.CategoryID IS NULL) where 1=1 ";
              if (chk_date.Checked == true)
              {
                  str += " and ( [CreatedOn] between '" + CommonLogic.Get_Date_From_String(txt_date_from.Text, 1);
                  str += "' and '" + CommonLogic.Get_Date_From_String(txt_date_to.Text, 2) + "' )";
              }
              if (string.IsNullOrEmpty(txttitle.Text.Trim()))
              {
                  str += string.Empty;
              }
              else
              {
                  str += " and p.Title like '%" + txttitle.Text.Trim() + "%'";
              }
              if (ddl_fromuser.SelectedItem.Text.ToString() == ".All")
              {
                  str += string.Empty;
              }
              else
              {
                  str += " and j.FromuserID = CONVERT(INT," + Convert.ToInt32(ddl_fromuser.SelectedValue.ToString()) + ")";
              }
              if (ddl_subcategories.SelectedItem.Text.ToString() == ".All")
              {
                  str += string.Empty;
              }
              else
              {
                  str += " and j.CategoryID = CONVERT(INT," + Convert.ToInt32(ddl_subcategories.SelectedValue.ToString()) + ")";
              }
              dt = obj.Get_Data_Table_From_Str(str);
              if (dt.Rows.Count &gt; 1)
              {
                  dt.Rows[0]["SubscriberCategory"] = "ALL";
                  var topRows = dt.AsEnumerable().FirstOrDefault();
                  egrd.DataSource = topRows;
                  egrd.DataBind();
              }
              else
              {
                  egrd.DataSource = dt;
                  egrd.DataBind();
              }
              ViewState["data"] = dt;
  </code></pre>
  
  <p>how ever this gives me error like no JobID found to this record set. whether it is still exists in record set.</p>
  
  <p>please help me...</p>
  
  <p><strong>well I tried this solution but no success...……..</strong></p>
  
  <pre><code> if (dt.Rows.Count &gt; 1)
              {
                  dt.Rows[0]["SubscriberCategory"] = "ALL";
                  var topRows = dt.AsEnumerable().GroupBy(j =&gt; j.Field&lt;int&gt;("JobID")).Select(j =&gt; j.First()).ToList();
                  egrd.DataSource = topRows;
                  egrd.DataBind();
              }
  </code></pre>
  
  <p>it's gives me exception like <code>DataBinding: 'System.Data.DataRow' does not contain a property with the name 'JobID'.</code></p>