ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Microsoft Related  >>  ASP.NET
 
 


 

 
 Visual Basic interview questions  Visual Basic Interview Questions
 C Sharp interview questions  C Sharp Interview Questions
 ASP.NET interview questions  ASP.NET Interview Questions
 VB.NET interview questions  VB.NET Interview Questions
 COM+ interview questions  COM+ Interview Questions
 ADO.NET interview questions  ADO.NET Interview Questions
 IIS interview questions  IIS Interview Questions
 MTS interview questions  MTS Interview Questions
 Crystal Reports interview questions  Crystal Reports Interview Questions
 BizTalk interview questions  BizTalk Interview Questions
 Dot Net interview questions  Dot Net Interview Questions
 Exchange Server interview questions  Exchange Server Interview Questions
 SharePoint interview questions  SharePoint Interview Questions
 Microsoft Related AllOther interview questions  Microsoft Related AllOther Interview Questions
Question
I have a datagrid of 10 rows and I am updating the fifth 
row using template column edit. How wil u know that the row 
is updated, so that it can be send to database for updating 
the respective table?
 Question Submitted By :: Sani
I also faced this Question!!     Rank Answer Posted By  
 
  Re: I have a datagrid of 10 rows and I am updating the fifth row using template column edit. How wil u know that the row is updated, so that it can be send to database for updating the respective table?
Answer
# 1
TestPage.aspx
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
    <script language="javascript" type="text/javascript">
    function Edit(TargetRow)
    {
        var txt =document.getElementById
(TargetRow.id).innerText;
    AsyncHit("ProcesssPage.aspx?"+txt)
    }

function AsyncHit(RemoteUrl) 
    {
       var ParamString="xx";
        if (window.XMLHttpRequest) 
        { // For Firefox,Mozilla, Safari & IE 7 and above 
etc 
            xmlhttp=new XMLHttpRequest();
        } 
        else if (window.ActiveXObject) 
        { //For IE 
            xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
        }
        
        if (typeof(xmlhttp)=='object') 
        {
            xmlhttp.onreadystatechange=GetResponse;
            xmlhttp.open('POST', RemoteUrl, true);
            document.getElementById
("prg_bar").innerHTML="<img src='../images/ajax-
loader1.gif'/>";
            xmlhttp.send(ParamString);
        }
    }


function GetResponse()
 {
   if (xmlhttp.readyState==4) 
   { 
     document.getElementById("prg_bar").innerHTML="*";
      if (xmlhttp.status==200) 
      { 
         HandleResponse(xmlhttp.responseText);
      }
      else
      {
         HandleResponse("-1");
      }
   }
}
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="GridView1" runat="server" 
OnRowCreated="GridView1_RowCreated">
        </asp:GridView>
    
    </div>
    </form>
</body>
</html>
-----------------------------------------------------------
TestPage.aspx.cs
protected void Page_Load(object sender, EventArgs e)
    {
        ViewState.Add("shape", "circle");
        string shapes = ViewState["shape"].ToString();
        Application["a"] = "zzz";
        

    }
protected void GridView1_RowCreated(object sender, 
GridViewRowEventArgs e)
    {
        GridView1.Rows[RowCount].Attributes.Add("Row_" + 
RowCount.ToString(), " onclick=javascript:Edit(this)");
        RowCount++;
    }
 
Is This Answer Correct ?    1 Yes 0 No
Jatinder Walia
 
  Re: I have a datagrid of 10 rows and I am updating the fifth row using template column edit. How wil u know that the row is updated, so that it can be send to database for updating the respective table?
Answer
# 2
Create Your Source Code As Follows:
1)Create a new website Project
2)Create a page called default.aspx(you will get it if you 
are using Microsoft IDE)
3)Paste the following code on Default.aspx
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
    <script language="javascript" type="text/javascript">
    var CurrentlyEditingRow=1;
    function Edit(TargetRow)
    {
        CurrentlyEditingRow=TargetRow.id;
        var txt =document.getElementById
(TargetRow.id).innerText;
        AsyncHit("Editpage.aspx?
r="+TargetRow.id+"&val="+txt,"");
    }
    function AsyncHit(RemoteUrl) 
    {
       
        if (window.XMLHttpRequest) 
        { // For Firefox,Mozilla, Safari & IE 7 and above 
etc 
            xmlhttp=new XMLHttpRequest();
        } 
        else if (window.ActiveXObject) 
        { //For IE 
            xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
        }
        
        if (typeof(xmlhttp)=='object') 
        {
            xmlhttp.onreadystatechange=GetResponse;
            xmlhttp.open('POST', RemoteUrl, true);
            document.getElementById
("prg_bar").innerHTML="Sending..Please Wait..";
            xmlhttp.send("");
        }
    }


function GetResponse()
 {
   if (xmlhttp.readyState==4) 
   { 
     document.getElementById("prg_bar").innerHTML="";
      if (xmlhttp.status==200) 
      { 
         HandleResponse(xmlhttp.responseText);
      }
      else
      {
         HandleResponse("-1");
      }
   }
}
function HandleResponse(Response)
{
    document.getElementById
(CurrentlyEditingRow).innerText=Response;
}
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table>
        <tr>
        <td id="prg_bar">
        
        </td>
        
        </tr>
        <tr>
        
        <td>
            <asp:GridView ID="GridView1" runat="server" 
AutoGenerateColumns="False">
            <Columns>
                <asp:BoundField 
AccessibleHeaderText="Field1" DataField="name" 
HeaderText="Field1" />
                <asp:BoundField 
AccessibleHeaderText="field2" DataField="id" 
HeaderText="field2" />
            </Columns>
        </asp:GridView>    
        </td>
        </tr>
        </table>
        
    </div>
    </form>
</body>
</html>


4)Paste The Following Code On Default.aspx.cs
/*NOTE:Create ur own class for fetching some data from 
dataset ie create your own DATABL.cs class for fetching 
data into dataset.This example has been programmed to work 
with 2 fields in Grid only and the second field must be 
numeric,otherwise the logic will crash in current 
scenario.Offcourse you can change it as per yor 
requirement.*/

int RowCount = 1;
    protected void Page_Load(object sender, EventArgs e)
    {
        string strQuery = "select name,id from IMPORTEXCEL 
where rownum<20";
        
               DataBL odbl = new DataBL();
        DataSet ds = odbl.getDataSet("qry", strQuery);
        GridView1.DataSource = ds.Tables[0];
        GridView1.DataBind();
        int ColCount=0;
        for (RowCount = 0; RowCount < GridView1.Rows.Count; 
RowCount++)
        {
            for (ColCount = 1; ColCount < 
GridView1.Columns.Count; ColCount++)
            {
                GridView1.Rows[RowCount].Cells
[ColCount].Attributes.Add("Id", RowCount.ToString() + "_" + 
ColCount.ToString());
                GridView1.Rows[RowCount].Cells
[ColCount].Attributes.Add("OnClick", "Javascript:Edit
(this)");
            }
        }
    }

5)Now Create a new aspx Page with the name EditPage.aspx
6)Change the aspx of EditPage.aspx as under
<%@ Page Language="C#" AutoEventWireup="true" 
CodeFile="EditPage.aspx.cs" Inherits="EditPage" %>

ie nothing should be on this aspx page except the first 
default line of code on this page..ie no HTML

7)Paste The following code on EditPage.aspx.cs
protected void Page_Load(object sender, EventArgs e)
    {
        
        string Values = Request.QueryString["val"];
        if (int.Parse(Values) > 30)
            Response.Write("High");
        else
            Response.Write("Low");
    }
8)Now run this application.
9)Now when you click on the first cell on any row in the 
grid,nothing happens.However,when you click on the second 
row,you will find "Sending..Please Wait.." written briefly 
and the number will change to values HIGH,if value is 
greater than 30 and LOW if vice-versa.Hope this will help 
someone.....
 
Is This Answer Correct ?    2 Yes 0 No
Jatinder Walia
 
 
 
  Re: I have a datagrid of 10 rows and I am updating the fifth row using template column edit. How wil u know that the row is updated, so that it can be send to database for updating the respective table?
Answer
# 3
In GridView_RowUpdating Event, you get e.RowIndex which can
be used for finding out row edited.

e.g. : gridview.Rows[e.RowIndex]
 
Is This Answer Correct ?    4 Yes 0 No
Aric Smith
 

 
 
 
Other ASP.NET Interview Questions
 
  Question Asked @ Answers
 
how to use html code in asp source code?  1
Descrie about response.buffer and repsonse.flush ? Cognizent1
Different type of validation controls in asp.net ? Keane-India-Ltd1
What’s the difference between Response.Write() andResponse.Output.Write()?  1
Explain Assemblies?,Difference between Panel and GroupBox?,Differences between ASP and ASP.NET?  1
what are the ways to improve performance in .net application? Mind-Tree3
What tags do you need to add within the asp:datagrid tags to bind columns manually?  2
If I m using Session State Partioning where I have partitioned my session into 4 servers then how can I know that my session will be stored on which server?  1
Can the validation be done in the server side? Or this can be done only in the Client side?  2
What are the different authentication modes in the .NET environment?  2
what is diffrence between debug class and trace class in asp.net ?  2
is it possible to persiste customize object in view state? how it is?  2
I have a method written in WebForm (means .aspx page) & now I want to call this method in WebUserControl (means .ascx page) what should I have to do? Patni1
what is session ?how sessions are handeled in application? write the clauses of sql server in their order. Olive-Tech2
How to write unmanaged code and how to identify whether the code is managed / unmanaged ? Accenture1
About duration in caching technique ? Accenture2
Suppose you want a certain ASP.NET function executed on MouseOver overa certain button. Where do you add an event handler? Visual-Soft3
What is the other method, other than GET and POST, in ASP.NET?  3
what is the difference b/w .net 1.1 and 2.0 ? Polaris2
How to deploy the Asp.Net Project ?  3
 
For more ASP.NET Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com