LBGUC04
asked on
Convert Gridview VB to C#
Can anyone help me convert the below from vb to c#
Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls. GridViewRo wEventArgs ) Handles GridView1.RowCreated
    If DataBinder.Eval(e.Row.Data Item, "alert") = 1 Then
      CType(e.Row.FindControl("L abel2"), Label).BackColor = Drawing.Color.Red
      CType(e.Row.FindControl("L abel2"), Label).ForeColor = Drawing.Color.White
      CType(e.Row.FindControl("L abel3"), Label).BackColor = Drawing.Color.Red
      CType(e.Row.FindControl("L abel3"), Label).ForeColor = Drawing.Color.White
      CType(e.Row.FindControl("L abel4"), Label).BackColor = Drawing.Color.Red
      CType(e.Row.FindControl("L abel4"), Label).ForeColor = Drawing.Color.White
      CType(e.Row.FindControl("L abel5"), Label).BackColor = Drawing.Color.Red
      CType(e.Row.FindControl("L abel5"), Label).ForeColor = Drawing.Color.White
      CType(e.Row.FindControl("L abel6"), Label).BackColor = Drawing.Color.Red
      CType(e.Row.FindControl("L abel6"), Label).ForeColor = Drawing.Color.White
      CType(e.Row.FindControl("L abel7"), Label).BackColor = Drawing.Color.Red
      CType(e.Row.FindControl("L abel7"), Label).ForeColor = Drawing.Color.White
      CType(e.Row.FindControl("L abel8"), Label).BackColor = Drawing.Color.Red
      CType(e.Row.FindControl("L abel8"), Label).ForeColor = Drawing.Color.White
      CType(e.Row.FindControl("L abel9"), Label).BackColor = Drawing.Color.Red
      CType(e.Row.FindControl("L abel9"), Label).ForeColor = Drawing.Color.White
      CType(e.Row.FindControl("L abel11"), Label).BackColor = Drawing.Color.Red
      CType(e.Row.FindControl("L abel11"), Label).ForeColor = Drawing.Color.White
    End If
    If DataBinder.Eval(e.Row.Data Item, "alert") = 2 Then
      CType(e.Row.FindControl("L abel2"), Label).BackColor = Drawing.Color.Orange
      CType(e.Row.FindControl("L abel2"), Label).ForeColor = Drawing.Color.White
      CType(e.Row.FindControl("L abel3"), Label).BackColor = Drawing.Color.Orange
      CType(e.Row.FindControl("L abel3"), Label).ForeColor = Drawing.Color.White
      CType(e.Row.FindControl("L abel4"), Label).BackColor = Drawing.Color.Orange
      CType(e.Row.FindControl("L abel4"), Label).ForeColor = Drawing.Color.White
      CType(e.Row.FindControl("L abel5"), Label).BackColor = Drawing.Color.Orange
      CType(e.Row.FindControl("L abel5"), Label).ForeColor = Drawing.Color.White
      CType(e.Row.FindControl("L abel6"), Label).BackColor = Drawing.Color.Orange
      CType(e.Row.FindControl("L abel6"), Label).ForeColor = Drawing.Color.White
      CType(e.Row.FindControl("L abel7"), Label).BackColor = Drawing.Color.Orange
      CType(e.Row.FindControl("L abel7"), Label).ForeColor = Drawing.Color.White
      CType(e.Row.FindControl("L abel8"), Label).BackColor = Drawing.Color.Orange
      CType(e.Row.FindControl("L abel8"), Label).ForeColor = Drawing.Color.White
      CType(e.Row.FindControl("L abel9"), Label).BackColor = Drawing.Color.Orange
      CType(e.Row.FindControl("L abel9"), Label).ForeColor = Drawing.Color.White
      CType(e.Row.FindControl("L abel11"), Label).BackColor = Drawing.Color.Orange
      CType(e.Row.FindControl("L abel11"), Label).ForeColor = Drawing.Color.White
    End If
  End Sub
Protected Sub GridView1_RowCreated(ByVal
    If DataBinder.Eval(e.Row.Data
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
    End If
    If DataBinder.Eval(e.Row.Data
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
      CType(e.Row.FindControl("L
    End If
  End Sub
protected void GridView1_RowCreated(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
if (DataBinder.Eval(e.Row.DataItem, "alert") == 1)
{
(e.Row.FindControl("Label2") as Label).BackColor = Drawing.Color.Red;
(e.Row.FindControl("Label2") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label3") as Label).BackColor = Drawing.Color.Red;
(e.Row.FindControl("Label3") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label4") as Label).BackColor = Drawing.Color.Red;
(e.Row.FindControl("Label4") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label5") as Label).BackColor = Drawing.Color.Red;
(e.Row.FindControl("Label5") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label6") as Label).BackColor = Drawing.Color.Red;
(e.Row.FindControl("Label6") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label7") as Label).BackColor = Drawing.Color.Red;
(e.Row.FindControl("Label7") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label8") as Label).BackColor = Drawing.Color.Red;
(e.Row.FindControl("Label8") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label9") as Label).BackColor = Drawing.Color.Red;
(e.Row.FindControl("Label9") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label11") as Label).BackColor = Drawing.Color.Red;
(e.Row.FindControl("Label11") as Label).ForeColor = Drawing.Color.White;
}
if (DataBinder.Eval(e.Row.DataItem, "alert") == 2)
{
(e.Row.FindControl("Label2") as Label).BackColor = Drawing.Color.Orange;
(e.Row.FindControl("Label2") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label3") as Label).BackColor = Drawing.Color.Orange;
(e.Row.FindControl("Label3") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label4") as Label).BackColor = Drawing.Color.Orange;
(e.Row.FindControl("Label4") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label5") as Label).BackColor = Drawing.Color.Orange;
(e.Row.FindControl("Label5") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label6") as Label).BackColor = Drawing.Color.Orange;
(e.Row.FindControl("Label6") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label7") as Label).BackColor = Drawing.Color.Orange;
(e.Row.FindControl("Label7") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label8") as Label).BackColor = Drawing.Color.Orange;
(e.Row.FindControl("Label8") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label9") as Label).BackColor = Drawing.Color.Orange;
(e.Row.FindControl("Label9") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label11") as Label).BackColor = Drawing.Color.Orange;
(e.Row.FindControl("Label11") as Label).ForeColor = Drawing.Color.White;
}
}
protected void  // ERROR: Handles clauses are not supported in C#
GridView1_RowCreated(objec t sender, System.Web.UI.WebControls. GridViewRo wEventArgs e)
{
      if (DataBinder.Eval(e.Row.Dat aItem, "alert") == 1) {
           ((Label)e.Row.FindControl( "Label2")) .BackColor = Drawing.Color.Red;
           ((Label)e.Row.FindControl( "Label2")) .ForeColor = Drawing.Color.White;
           ((Label)e.Row.FindControl( "Label3")) .BackColor = Drawing.Color.Red;
           ((Label)e.Row.FindControl( "Label3")) .ForeColor = Drawing.Color.White;
           ((Label)e.Row.FindControl( "Label4")) .BackColor = Drawing.Color.Red;
           ((Label)e.Row.FindControl( "Label4")) .ForeColor = Drawing.Color.White;
           ((Label)e.Row.FindControl( "Label5")) .BackColor = Drawing.Color.Red;
           ((Label)e.Row.FindControl( "Label5")) .ForeColor = Drawing.Color.White;
           ((Label)e.Row.FindControl( "Label6")) .BackColor = Drawing.Color.Red;
           ((Label)e.Row.FindControl( "Label6")) .ForeColor = Drawing.Color.White;
           ((Label)e.Row.FindControl( "Label7")) .BackColor = Drawing.Color.Red;
           ((Label)e.Row.FindControl( "Label7")) .ForeColor = Drawing.Color.White;
           ((Label)e.Row.FindControl( "Label8")) .BackColor = Drawing.Color.Red;
           ((Label)e.Row.FindControl( "Label8")) .ForeColor = Drawing.Color.White;
           ((Label)e.Row.FindControl( "Label9")) .BackColor = Drawing.Color.Red;
           ((Label)e.Row.FindControl( "Label9")) .ForeColor = Drawing.Color.White;
           ((Label)e.Row.FindControl( "Label11") ).BackColo r = Drawing.Color.Red;
           ((Label)e.Row.FindControl( "Label11") ).ForeColo r = Drawing.Color.White;
      }
      if (DataBinder.Eval(e.Row.Dat aItem, "alert") == 2) {
           ((Label)e.Row.FindControl( "Label2")) .BackColor = Drawing.Color.Orange;
           ((Label)e.Row.FindControl( "Label2")) .ForeColor = Drawing.Color.White;
           ((Label)e.Row.FindControl( "Label3")) .BackColor = Drawing.Color.Orange;
           ((Label)e.Row.FindControl( "Label3")) .ForeColor = Drawing.Color.White;
           ((Label)e.Row.FindControl( "Label4")) .BackColor = Drawing.Color.Orange;
           ((Label)e.Row.FindControl( "Label4")) .ForeColor = Drawing.Color.White;
           ((Label)e.Row.FindControl( "Label5")) .BackColor = Drawing.Color.Orange;
           ((Label)e.Row.FindControl( "Label5")) .ForeColor = Drawing.Color.White;
           ((Label)e.Row.FindControl( "Label6")) .BackColor = Drawing.Color.Orange;
           ((Label)e.Row.FindControl( "Label6")) .ForeColor = Drawing.Color.White;
           ((Label)e.Row.FindControl( "Label7")) .BackColor = Drawing.Color.Orange;
           ((Label)e.Row.FindControl( "Label7")) .ForeColor = Drawing.Color.White;
           ((Label)e.Row.FindControl( "Label8")) .BackColor = Drawing.Color.Orange;
           ((Label)e.Row.FindControl( "Label8")) .ForeColor = Drawing.Color.White;
           ((Label)e.Row.FindControl( "Label9")) .BackColor = Drawing.Color.Orange;
           ((Label)e.Row.FindControl( "Label9")) .ForeColor = Drawing.Color.White;
           ((Label)e.Row.FindControl( "Label11") ).BackColo r = Drawing.Color.Orange;
           ((Label)e.Row.FindControl( "Label11") ).ForeColo r = Drawing.Color.White;
      }
}
GridView1_RowCreated(objec
{
      if (DataBinder.Eval(e.Row.Dat
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
      }
      if (DataBinder.Eval(e.Row.Dat
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
           ((Label)e.Row.FindControl(
      }
}
ASKER
RajkumarGS:
I get the error
Error      1      Type or namespace definition, or end-of-file expected
carl_tawn:
I got a whole load of invalid token errors
chillyfrost:
I got this error
Error      1      Type or namespace definition, or end-of-file expected
ASKER
RajkumarGS: &Â chillyfrost:
I fixed the issue with the {} this is the error i get
Error      1      Operator '==' cannot be applied to operands of type 'object' and 'int'
I fixed the issue with the {} this is the error i get
Error      1      Operator '==' cannot be applied to operands of type 'object' and 'int'
I missed the opening brace. Should have been:
protected void GridView1_RowCreated(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
{
if (DataBinder.Eval(e.Row.DataItem, "alert") == 1)
{
(e.Row.FindControl("Label2") as Label).BackColor = Drawing.Color.Red;
(e.Row.FindControl("Label2") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label3") as Label).BackColor = Drawing.Color.Red;
(e.Row.FindControl("Label3") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label4") as Label).BackColor = Drawing.Color.Red;
(e.Row.FindControl("Label4") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label5") as Label).BackColor = Drawing.Color.Red;
(e.Row.FindControl("Label5") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label6") as Label).BackColor = Drawing.Color.Red;
(e.Row.FindControl("Label6") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label7") as Label).BackColor = Drawing.Color.Red;
(e.Row.FindControl("Label7") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label8") as Label).BackColor = Drawing.Color.Red;
(e.Row.FindControl("Label8") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label9") as Label).BackColor = Drawing.Color.Red;
(e.Row.FindControl("Label9") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label11") as Label).BackColor = Drawing.Color.Red;
(e.Row.FindControl("Label11") as Label).ForeColor = Drawing.Color.White;
}
if (DataBinder.Eval(e.Row.DataItem, "alert") == 2)
{
(e.Row.FindControl("Label2") as Label).BackColor = Drawing.Color.Orange;
(e.Row.FindControl("Label2") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label3") as Label).BackColor = Drawing.Color.Orange;
(e.Row.FindControl("Label3") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label4") as Label).BackColor = Drawing.Color.Orange;
(e.Row.FindControl("Label4") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label5") as Label).BackColor = Drawing.Color.Orange;
(e.Row.FindControl("Label5") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label6") as Label).BackColor = Drawing.Color.Orange;
(e.Row.FindControl("Label6") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label7") as Label).BackColor = Drawing.Color.Orange;
(e.Row.FindControl("Label7") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label8") as Label).BackColor = Drawing.Color.Orange;
(e.Row.FindControl("Label8") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label9") as Label).BackColor = Drawing.Color.Orange;
(e.Row.FindControl("Label9") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label11") as Label).BackColor = Drawing.Color.Orange;
(e.Row.FindControl("Label11") as Label).ForeColor = Drawing.Color.White;
}
}
>> Type or namespace definition, or end-of-file expected
This error will show when you placed the piece of code in wrong place.
For eg:- If you place this code inside page_load, it will show the same error. Because this is an individual procedure
Verify this
Raj
This error will show when you placed the piece of code in wrong place.
For eg:- If you place this code inside page_load, it will show the same error. Because this is an individual procedure
Verify this
Raj
ASKER
ok well for all of the examples i get the following and the DataBinder is underlines with a blue line
Error      1      Operator '==' cannot be applied to operands of type 'object' and 'int'
Error      1      Operator '==' cannot be applied to operands of type 'object' and 'int'
My code actually have the opening &Â closing brace properly. Are you sure you put it in correct place (not into another procedure /event)
Raj
Raj
You're either going to need to parse the value, or compare to a string:
if (Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "alert").ToString()) == 1)
{
// etc, etc
}
You need to cast
For eg:- Change
if ( DataBinder.Eval(e.Row.Data Item, "alert") == 1)
to
 if (Convert.ToInt32(DataBinde r.Eval(e.R ow.DataIte m, "alert")) == 1)
Raj
For eg:- Change
if ( DataBinder.Eval(e.Row.Data
to
 if (Convert.ToInt32(DataBinde
Raj
Of course, you could just cut your code in half and use:
protected void GridView1_RowCreated(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
{
int alert = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "alert").ToString());
Color backColor = (alert == 1 ? Drawing.Color.Red : Drawing.Color.Orange);
(e.Row.FindControl("Label2") as Label).BackColor = backColor;
(e.Row.FindControl("Label2") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label3") as Label).BackColor = backColor;
(e.Row.FindControl("Label3") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label4") as Label).BackColor = backColor;
(e.Row.FindControl("Label4") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label5") as Label).BackColor = backColor;
(e.Row.FindControl("Label5") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label6") as Label).BackColor = backColor;
(e.Row.FindControl("Label6") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label7") as Label).BackColor = backColor;
(e.Row.FindControl("Label7") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label8") as Label).BackColor = backColor;
(e.Row.FindControl("Label8") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label9") as Label).BackColor = backColor;
(e.Row.FindControl("Label9") as Label).ForeColor = Drawing.Color.White;
(e.Row.FindControl("Label11") as Label).BackColor = backColor;
(e.Row.FindControl("Label11") as Label).ForeColor = Drawing.Color.White;
}
}
ASKER
The page now runs but it isnt showing the highlighted rows. I placed a debug catch on the code but it didnt pause on this code at all?
That means the event handler isn't hooked up properly. Switch to design view, select your grid then, in the properties window click the lightning bolt (which is properties). Scroll down till you find RowCreated and then set its value to "GridView1_RowCreated".
ASKER
Thanks i have got that hooked up now
I am now seeing an eror on the convert
Line 49: Â Â protected void GridMain_RowCreated(object sender, System.Web.UI.WebControls. GridViewRo wEventArgs e)
Line 50: Â Â {
Line 51: Â Â Â Â if (Convert.ToInt32(DataBinde r.Eval(e.R ow.DataIte m, "alert").ToString()) == 1)
Line 52: Â Â Â Â {
Line 53: Â Â Â Â Â Â (e.Row.FindControl("Label2 ") as Label).BackColor = System.Drawing.Color.Red;
I am now seeing an eror on the convert
Line 49: Â Â protected void GridMain_RowCreated(object
Line 50: Â Â {
Line 51: Â Â Â Â if (Convert.ToInt32(DataBinde
Line 52: Â Â Â Â {
Line 53: Â Â Â Â Â Â (e.Row.FindControl("Label2
What error?
ASKER
Sorry i didnt copy it all
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceExcept ion: Object reference not set to an instance of an object.
Source Error:
Line 49: Â Â protected void GridMain_RowCreated(object sender, System.Web.UI.WebControls. GridViewRo wEventArgs e)
Line 50: Â Â {
Line 51: Â Â Â Â if (Convert.ToInt32(DataBinde r.Eval(e.R ow.DataIte m, "alert").ToString()) == 1)
Line 52: Â Â Â Â {
Line 53: Â Â Â Â Â Â (e.Row.FindControl("Label2 ") as Label).BackColor = System.Drawing.Color.Red;
Â
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceExcept
Source Error:
Line 49: Â Â protected void GridMain_RowCreated(object
Line 50: Â Â {
Line 51: Â Â Â Â if (Convert.ToInt32(DataBinde
Line 52: Â Â Â Â {
Line 53: Â Â Â Â Â Â (e.Row.FindControl("Label2
Â
OK, that means that either DataItem is null, or it can't find the label.
Odds are it is because it is also firing for the header row, which will not have an associated DataItem. Try wrapping it with an additional "if":
Odds are it is because it is also firing for the header row, which will not have an associated DataItem. Try wrapping it with an additional "if":
protected void GridMain_RowCreated(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "alert").ToString()) == 1)
{
(e.Row.FindControl("Label2") as Label).BackColor = System.Drawing.Color.Red;
....
}
}
}
ASKER
That did work tank you for your assistance it getting it working.
I dont have another question though. I am refreshing my gridview every 5 seconds using the script manager and update panel. Since putting in the row update code i get an error when the timer triggers
A runtime error has occured
sys.webforms.pagerequestma nagerserve rerrorexce ption: object reference not set to an instance of an object
I dont have another question though. I am refreshing my gridview every 5 seconds using the script manager and update panel. Since putting in the row update code i get an error when the timer triggers
A runtime error has occured
sys.webforms.pagerequestma
You'll need to put a breakpoint on the methods that draw your grid and see what is happening. ScriptManager messages are usually a bit vague.
ASKER
It look slike its happening because on timer event we get a e.Row.DataItem is null is there a way to almost say
coalesce(e.Row.DataItem,0)
or
isnull(e.Row.DataItem,0)
coalesce(e.Row.DataItem,0)
or
isnull(e.Row.DataItem,0)
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thats great its working now thank you for your assistance
ASKER
Very Helpful
http://www.developerfusion.com/tools/convert/vb-to-csharp/
Â
Open in new window
Regards
Raj