Solved

Set GridView column readonly to false if a condition is met

Posted on 2006-06-20
33
2,601 Views
Last Modified: 2007-12-19
Hi All

I am trying to set the justification column within my gridview to false if the asset column is a desktop. This is what I have:

    Protected Sub GridView1_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GridView1.RowEditing

        Dim index As Integer = GridView1.EditIndex
        Dim row As GridViewRow = GridView1.Rows(e.NewEditIndex)

        Dim sAsset As String = Me.GridView1.Rows(e.NewEditIndex).Cells(3).Text
        Dim sJustification As TextBox = CType(row.Cells(7).FindControl("TextBox1"), TextBox)

        If sAsset = "Desktop" Then
            sJustification.ReadOnly = False
        End If
    End Sub


********** Error I am getting is when I hit edit is  *********

System.NullReferenceException was unhandled by user code
  Message="Object reference not set to an instance of an object."
  Source="App_Web_xab4q8nh"
  StackTrace:
       at Assets_Targ_Edit.GridView1_RowEditing(Object sender, GridViewEditEventArgs e) in C:\WebSites\Dev\BusinessUnits\Assets_Targ_Edit.aspx.vb:line 110
       at System.Web.UI.WebControls.GridViewEditEventHandler.Invoke(Object sender, GridViewEditEventArgs e)
       at System.Web.UI.WebControls.GridView.OnRowEditing(GridViewEditEventArgs e)
       at System.Web.UI.WebControls.GridView.HandleEdit(Int32 rowIndex)
       at System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup)
       at System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Please help, thanks

Anthony
0
Comment
Question by:acancel
  • 17
  • 10
  • 6
33 Comments
 
LVL 4

Expert Comment

by:gregg1ep00
ID: 16946213
Which line is 110 (the one giving the error)?
0
 
LVL 15

Expert Comment

by:GavinMannion
ID: 16949292
My guess is that you are trying to CType a textbox that does not exist in Cell 7.....

As Gregg asked, which one is line 110?
0
 

Author Comment

by:acancel
ID: 16950733
Thanks for responding.

110 is "sJustification.ReadOnly = False"

I was able to populate some text into this field using "Me.GridView1.Rows(e.NewEditIndex).Cells(7).Text", so I confirmed that the column is being seen

I hear that this kind of functionality should actually be done on the client side utilizing javascript. Would you guys agree with that?
0
 
LVL 15

Expert Comment

by:GavinMannion
ID: 16950768
No I think it should be done in the codebehind.

When debugging does sJustification have any value? I still have the feeling it is finding the wrong cell.
Also try sJustification.Enabled = true
0
 

Author Comment

by:acancel
ID: 16950924
This is the error I get when I try enabled = true

System.NullReferenceException was unhandled by user code
  Message="Object reference not set to an instance of an object."
  Source="App_Web_8fuukekr"
  StackTrace:
       at Assets_Targ_Edit.GridView1_RowEditing(Object sender, GridViewEditEventArgs e) in C:\WebSites\Dev\BusinessUnits\Assets_Targ_Edit.aspx.vb:line 110
       at System.Web.UI.WebControls.GridViewEditEventHandler.Invoke(Object sender, GridViewEditEventArgs e)
       at System.Web.UI.WebControls.GridView.OnRowEditing(GridViewEditEventArgs e)
       at System.Web.UI.WebControls.GridView.HandleEdit(Int32 rowIndex)
       at System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup)
       at System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


How can test to see what column it is grabbing?
0
 
LVL 15

Expert Comment

by:GavinMannion
ID: 16950962
Put a breakpoint on line 109, then when debugging take a QuickWatch at sJustification.
0
 

Author Comment

by:acancel
ID: 16951031
This is what I get within the watch window
            
sJustification      Nothing      System.Web.UI.WebControls.TextBox
0
 
LVL 15

Expert Comment

by:GavinMannion
ID: 16951131
Okay I am stumped... it does seem to be casting correctly and your syntax looks fine....

What happens if you change it to say

sJustification.Text = "Test"

Does that work?
0
 

Author Comment

by:acancel
ID: 16951175
Ok,
I changed the code to following to try to do some testing

Dim sJustification As Label = CType(row.Cells(7).FindControl("Label1"), Label)

Label1 is the name of the field in the ItemTemplate. I have populated that field with "test"
When I hit edit, It seems to be picking up the text within that field now but it does not disable the field.

+            sJustification      {Text = "test"}      System.Web.UI.WebControls.Label


0
 
LVL 15

Expert Comment

by:GavinMannion
ID: 16951211
Well you cannot disable a label field.....

So is the textbox and the label in the same cell?
0
 

Author Comment

by:acancel
ID: 16951212
I have seen some post that there may be an issue whether the form is the itemtemplate or the edittemplate

This is my code in aspx for this field

<asp:TemplateField HeaderText="Other Comments" SortExpression="justification_comment_other" ConvertEmptyStringToNull="False">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("justification_comment_other") %>'></asp:TextBox>
                </EditItemTemplate>
                <ControlStyle Width="400px" />
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("justification_comment_other") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
0
 

Author Comment

by:acancel
ID: 16951303
Now what I am trying to do is to disable the justification field if the asset is a desktop. This asset type data is coming from a sql server, so it is already populated before hitting the edit button. So perhaps I need to place the vb code in another routine of the gridview? However, a user may have a laptop and a desktop at which point when they edit the laptop info, the justification field should be enabled for them to select a justification for the laptop. Dont know if that helps?
0
 
LVL 15

Expert Comment

by:GavinMannion
ID: 16951604
I am lost here, I can't find why it is not working... It all seems fine to me....

Move your code to the databound event and try this...

        Dim sAsset As String = Me.GridView1.Rows(e.NewEditIndex).Cells(3).Text

If e.item.itemType = ListItemType.EditItem Then
        Dim row As GridViewRow = GridView1.Rows(e.NewEditIndex)

        Dim sJustification As TextBox = CType(row.Cells(7).FindControl("TextBox1"), TextBox)

        If sAsset = "Desktop" Then
            sJustification.ReadOnly = False
        End If

End If

0
 

Author Comment

by:acancel
ID: 16952518
I am now getting

Error      1      'NewEditIndex' is not a member of 'System.EventArgs'.      C:\WebSites\Dev\BusinessUnits\Assets_Targ_Edit.aspx.vb      102      50      C:\WebSites\Dev\

I placed in both databound and row databound
0
 
LVL 4

Expert Comment

by:gregg1ep00
ID: 16952890
Instead of doing all this guessing in cells, can you just do this?  You'll need to move this code back into your RowEditing handler.

Dim sJustification As TextBox = CType( row.FindControl( "TextBox1" ), TextBox)
0
 
LVL 4

Expert Comment

by:gregg1ep00
ID: 16952906
Actually, it may help to see the generated HTML of this page, so we can figure out which naming container the textbox is in (i.e., is it the row or the cell).
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:acancel
ID: 16952989
Ok, this is the vb code now, still get nothing

    Protected Sub GridView1_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GridView1.RowEditing

        Dim row As GridViewRow = GridView1.Rows(e.NewEditIndex)

        Dim sAsset As String = row.Cells(3).Text
        Dim sJustification As TextBox = CType(row.FindControl("TextBox1"), TextBox)

        If sAsset = "Desktop" Then
            sJustification.ReadOnly = True
        End If
    End Sub

*****************

This is the html code of the page



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head><title>
      Asset Targeting
</title><style type="text/css">
      .ctl00_TreeView1_0 { color:Black;font-family:Tahoma;font-size:8pt;text-decoration:none; }
      .ctl00_TreeView1_1 { color:Black;font-family:Tahoma;font-size:8pt; }
      .ctl00_TreeView1_2 { padding:2px 2px 2px 2px; }
      .ctl00_TreeView1_3 { color:Black;font-weight:normal; }
      .ctl00_TreeView1_4 {  }
      .ctl00_TreeView1_5 {  }
      .ctl00_TreeView1_6 { background-color:#B5B5B5;padding:0px 0px 0px 0px; }
      .ctl00_TreeView1_7 { color:#6666AA;text-decoration:underline; }
      .ctl00_TreeView1_8 { color:#6666AA;text-decoration:underline; }

</style></head>
<body leftMargin="0" topMargin="0" >
    <form name="aspnetForm" method="post" action="Assets_Targ_Edit.aspx" id="aspnetForm">
<div>
<input type="hidden" name="ctl00_TreeView1_ExpandState" id="ctl00_TreeView1_ExpandState" value="nccnnnnnccnn" />
<input type="hidden" name="ctl00_TreeView1_SelectedNode" id="ctl00_TreeView1_SelectedNode" value="" />
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="ctl00_TreeView1_PopulateLog" id="ctl00_TreeView1_PopulateLog" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="2EQ8wrC/4lTZXcf3E/NMvUkFV4RHVgfCqC9aZnibY//mj3EzPmP/TcrWNUgsC5WKd6BIZ/64fUxEJHS8vq+CCOgzeJmPlxk5Y7l82226hNaTzwPUPvWf/66fKuok3UznBVsXGZi2aAZge03M/i4qjToO790ugsms9Jo/rmGh7Yo0GqOs+hRfzU4QusBEcoAA+sm1lKpQbry63s/V8Zt4BCkMnrqVBKRPE+Nw1PxuolyJq5poXO1gPp43rNiJjnZN444to62hjgiCZr2qbCPI6q7YnQjHraka5zQAvwZUmQNCFr4u8lg4IJfk88U+8jh1uo2CAalPTYr7TaxUPj23mkDszECGSpzJ2EyVCtvESqfoRtQl2DDalU6keXi51BzahtAm2W+ByIZuIz/iRkZX+P2qhoMVdmKbhHueJWQ4TTn+G0PhhccJhD1NUf3gqS32+IS4ijKpu6liMIqWonhdFQnSYRCye4cCn7wvubGdk9njLRbnf6HIQDWYkclttOopXDd8ZnpoX2tdlQtV6bK9Epbpwa40vlPAMFg39PnGW86aWiewtsFpZkdVaJYxqp0AzZ5Hz5BkYIwHESP0ojqzKNINaMsTlmJA4LQErpmujwNwTOHTK+yPwXdpAtDf/VSaeZ2spL4j+MGbG3AnlRIryYh+DyE5O17aEmbwyZ/mq2q01deaCIBjDO4xGsIVn+s3a9NE8XxNtXp4y7AAqRSaAefYtAvOwUskNynbxeLqArYNPh7YHpX1+g3xoqBZS3NqMhxz0wVBy1aSL34iNwhiXUu66IWmWfUqJC8rdOLizcPNed8wEKKStTsY3jf6cszsH/Zi+79BGRHKW4eTvcmrA30oeNB14mMQG/iXyBlZ/x6qMSRrAhtSLrasbJ2dEdAuN0t/uayLw01TKr5ZaQG15d+Cbibjfxta/9tqc1e5Y3CpIVtMwQlPqKQmdVTode2IRX4KX/ejBIIhPYR3Wr/BZXjWhLmKYv9zcOKPGTZGRGn3qDGUNynOx3g06jA1cvB9vZ4iO5z+erlib6pXl4syJWSx2uPSec7IOPYIVZ4AHSkqLfd5I9t6MVBTSTQcuk0zku2uFJibuo67xgavDtcvky657Eoyz+TBPbil2snXice1ipnwltQd+QTcbUWv8YeofZfdhEIYXg3Nq/ucbHtD1H7kS85l6GFD3V47sIDRNmRjCMJpp1rxz15fSU/hEGIGAw4tXpuLZk/pw0kXl/kiDLHPhH5+BWzCruM+HXfJ6vohVT7Rb2PO6snTeXpA37m/6vT56dxkQwf+RY9G/xrShXi2SaPwoZe+6m8GuWDOSp071Y2eX0ClVw74/8ufsvQv0no4hGxZOktJlc8RZML1UaZ4b/Yj9d3Jp8XW+Nf049H9XixFPUZAHppKSMqNeWNLcOtvgl5nIdDKK8acO8tlZOo1Sr0brLj66J8isSA6oTiVGWmBa8ZYK0E5kbAEUg70zGqoHud/KkQ/dTiD11KJzpDj8DDZVsvGZhx6r+qGJjyqqlsJA2FTLgU/oYZVOKe9Lzkk7c1M73KkrggP3JPgu3cXJ0q4nosANAY65Zo/PoJQCyr5wVuWtTbdL+2+/8N1V713BlxPN6pcmWCGTOkRIFbgPVSky9nF4iOvZQbc9mxqS+XDOj+o903Ajq/laG5YktimHGjiuNU+6bKROUVmCZ8eVWCVag1a4ODzZ6cs9jGn8pw2u4bGQUQ7m5Fgem+rWQ+vkX81k1lXBbqb899jp7j01aKVHv5/RO0bM9TWCXuDKhdaYIyIPjx5YYcIs+oO1RIs3T8q+VwaLQLQ7c9gw6gKeL2M/xLRWCVlN3fE2XXSz6B7MKHZakiYEhXhdOc7PmqQQatfyg2X3mkpczxy6x0YxMP36dk1HJoLmxErsAar9VL5KI3nyctW1Jkro0ABym8sGzoXUcbGlBy79vVS5zmySci45m4okHhUoCNMvF/FdukV9OhaFEdk8VZjHnN5ivzwdwMgX7JiwtsxVLMsuf5wSEJFvJI3kNu1Ch0gwJy32BXz5z4Eiey7Ue0kMD3F8KpbIz7cpumganq8fPKuJfQiA9uCBghF/eg62svH9TCPy2eryDvOVmK1q02HeEkE1r+YOHSWzaK4hTsOZXELU7LpMhrPWN+QmugbPbU8lTUQIxpZ38+TEPNlLr93/RX35q1bEBq7USR7nnxuVpPNx8IDG4Xb28OvznTT0AZdfZ/fHdZ0Hs1uHQCLYxRKAgOmKyGS6K6xFH0vVKdVHPevWBzkoBIyf5o0x+6UWc7beMacW/0jmf9RUt2pTOUOyscBdoBCnqspE9NGHhJ66SWoSg==" />
</div>

<script type="text/javascript">
<!--
var theForm = document.forms['aspnetForm'];
if (!theForm) {
    theForm = document.aspnetForm;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
// -->
</script>


<script src="/Dev/WebResource.axd?d=_hZ35Yzym2UChE0GMusDVw2&amp;t=632826895366249935" type="text/javascript"></script>


<script src="/Dev/WebResource.axd?d=1oJGo_JgDlJ5o9ITSgAwoA2&amp;t=632826895366249935" type="text/javascript"></script>
<script>
<!--
    function TreeView_PopulateNodeDoCallBack(context,param) {
        WebForm_DoCallback(context.data.treeViewID,param,TreeView_ProcessNodeData,context,TreeView_ProcessNodeData,false);
    }
// -->
</script>

    <div>
        <table border="1" cellpadding="10" cellspacing="0" style="height: 100%; width: 100%;" bordercolor="gainsboro" width="740">
            <tr>
                <td colspan="2" style="height: 1px; text-align: left" valign="top" bgcolor="lightsteelblue">
                    <span style="font-size: 24pt; font-family: Tahoma"><strong>Carpenter PC Refresh Project<br />
                    </strong><span style="font-size: 16pt">Interactive Reporting and Analysis Web Site<br />
                        <span style="font-size: 12pt">Pilot Date: August 1st, 2006</span></span></span></td>
            </tr>
            <tr style="font-size: 12pt">
                <td valign="top" style="position: static; height: 143px; width: 203px;" bgcolor="cornsilk">
                    <a href="#ctl00_TreeView1_SkipLink"><img alt="Skip Navigation Links." src="/Dev/WebResource.axd?d=71FownfIZ1GTwYF1zqLZGA2&amp;t=632826895366249935" width="0" height="0" style="border-width:0px;" /></a><div id="ctl00_TreeView1" style="color:Black;font-family:Tahoma;font-size:8pt;width:100px;">
      <table cellpadding="0" cellspacing="0" style="border-width:0;">
            <tr>
                  <td><img src="/Dev/WebResource.axd?d=b59ugrze69gFOlWrsTJRBvZVcC7tXFDhEHfixbHutoptPjWsga1qNdYShuP0e_vQ0&amp;t=632826895366249935" alt="" /></td><td><a href="../Home.aspx" id="ctl00_TreeView1t0i"><img src="/Dev/WebResource.axd?d=b59ugrze69gFOlWrsTJRBkZTwTSz80oVog6LfWZeI2SbNRdwZGDBKCdSx6S-Nhbq0&amp;t=632826895366249935" alt="" style="border-width:0;" /></a></td><td class="ctl00_TreeView1_2" onmouseover="TreeView_HoverNode(ctl00_TreeView1_Data, this)" onmouseout="TreeView_UnhoverNode(this)" style="white-space:nowrap;"><a class="ctl00_TreeView1_0 ctl00_TreeView1_1" href="../Home.aspx" id="ctl00_TreeView1t0">Home</a></td>
            </tr><tr style="height:0px;">
                  <td></td>
            </tr>
      </table><table cellpadding="0" cellspacing="0" style="border-width:0;">
            <tr style="height:0px;">
                  <td></td>
            </tr><tr>
                  <td><a id="ctl00_TreeView1n1" href="javascript:TreeView_ToggleNode(ctl00_TreeView1_Data,1,ctl00_TreeView1n1,' ',ctl00_TreeView1n1Nodes)"><img src="/Dev/WebResource.axd?d=b59ugrze69gFOlWrsTJRBgNVlyAJAHCqeG-8XMFdD3rGUMQTuUppu1UgAzALMNzg0&amp;t=632826895366249935" alt="Expand Assets" style="border-width:0;" /></a></td><td><a href="javascript:TreeView_ToggleNode(ctl00_TreeView1_Data,1,ctl00_TreeView1n1,' ',ctl00_TreeView1n1Nodes)" id="ctl00_TreeView1t1i"><img src="/Dev/WebResource.axd?d=b59ugrze69gFOlWrsTJRBm4zqVuXmvhC4DMj08JPEkisclklYwxhcrxnEwJMBDUK0&amp;t=632826895366249935" alt="" style="border-width:0;" /></a></td><td class="ctl00_TreeView1_2" onmouseover="TreeView_HoverNode(ctl00_TreeView1_Data, this)" onmouseout="TreeView_UnhoverNode(this)" style="white-space:nowrap;"><a class="ctl00_TreeView1_0 ctl00_TreeView1_1" href="javascript:TreeView_ToggleNode(ctl00_TreeView1_Data,1,ctl00_TreeView1n1,' ',ctl00_TreeView1n1Nodes)" id="ctl00_TreeView1t1">Assets</a></td>
            </tr><tr style="height:0px;">
                  <td></td>
            </tr>
      </table><div id="ctl00_TreeView1n1Nodes" style="display:none;">
            <table cellpadding="0" cellspacing="0" style="border-width:0;">
                  <tr style="height:0px;">
                        <td></td>
                  </tr><tr>
                        <td><div style="width:15px;height:1px"></div></td><td><a id="ctl00_TreeView1n2" href="javascript:TreeView_ToggleNode(ctl00_TreeView1_Data,2,ctl00_TreeView1n2,' ',ctl00_TreeView1n2Nodes)"><img src="/Dev/WebResource.axd?d=b59ugrze69gFOlWrsTJRBgNVlyAJAHCqeG-8XMFdD3rGUMQTuUppu1UgAzALMNzg0&amp;t=632826895366249935" alt="Expand Asset Targeting" style="border-width:0;" /></a></td><td><a href="javascript:__doPostBack('ctl00$TreeView1','sApplications\\Asset Targeting')" onclick="TreeView_SelectNode(ctl00_TreeView1_Data, this,'ctl00_TreeView1t2');" id="ctl00_TreeView1t2i"><img src="/Dev/WebResource.axd?d=b59ugrze69gFOlWrsTJRBpyjAtyWgUX6aL4TwHXfx29r0ecVaA_hCE3_vMdS1yFt0&amp;t=632826895366249935" alt="" style="border-width:0;" /></a></td><td class="ctl00_TreeView1_2 ctl00_TreeView1_4" onmouseover="TreeView_HoverNode(ctl00_TreeView1_Data, this)" onmouseout="TreeView_UnhoverNode(this)" style="white-space:nowrap;"><a class="ctl00_TreeView1_0 ctl00_TreeView1_1 ctl00_TreeView1_3" href="javascript:__doPostBack('ctl00$TreeView1','sApplications\\Asset Targeting')" onclick="TreeView_SelectNode(ctl00_TreeView1_Data, this,'ctl00_TreeView1t2');" id="ctl00_TreeView1t2">Asset Targeting</a></td>
                  </tr><tr style="height:0px;">
                        <td></td>
                  </tr>
            </table><div id="ctl00_TreeView1n2Nodes" style="display:none;">
                  <table cellpadding="0" cellspacing="0" style="border-width:0;">
                        <tr style="height:0px;">
                              <td></td>
                        </tr><tr>
                              <td><div style="width:15px;height:1px"></div></td><td><div style="width:15px;height:1px"></div></td><td><img src="/Dev/WebResource.axd?d=b59ugrze69gFOlWrsTJRBvZVcC7tXFDhEHfixbHutoptPjWsga1qNdYShuP0e_vQ0&amp;t=632826895366249935" alt="" /></td><td><a href="Assets_Targ_Edit.aspx" id="ctl00_TreeView1t3i"><img src="/Dev/WebResource.axd?d=b59ugrze69gFOlWrsTJRBkZTwTSz80oVog6LfWZeI2SbNRdwZGDBKCdSx6S-Nhbq0&amp;t=632826895366249935" alt="" style="border-width:0;" /></a></td><td class="ctl00_TreeView1_2" onmouseover="TreeView_HoverNode(ctl00_TreeView1_Data, this)" onmouseout="TreeView_UnhoverNode(this)" style="white-space:nowrap;"><a class="ctl00_TreeView1_0 ctl00_TreeView1_1" href="Assets_Targ_Edit.aspx" id="ctl00_TreeView1t3">Users</a></td>
                        </tr><tr style="height:0px;">
                              <td></td>
                        </tr>
                  </table><table cellpadding="0" cellspacing="0" style="border-width:0;">
                        <tr style="height:0px;">
                              <td></td>
                        </tr><tr>
                              <td><div style="width:15px;height:1px"></div></td><td><div style="width:15px;height:1px"></div></td><td><img src="/Dev/WebResource.axd?d=b59ugrze69gFOlWrsTJRBvZVcC7tXFDhEHfixbHutoptPjWsga1qNdYShuP0e_vQ0&amp;t=632826895366249935" alt="" /></td><td><a href="../adminmenu.aspx" id="ctl00_TreeView1t4i"><img src="/Dev/WebResource.axd?d=b59ugrze69gFOlWrsTJRBkZTwTSz80oVog6LfWZeI2SbNRdwZGDBKCdSx6S-Nhbq0&amp;t=632826895366249935" alt="" style="border-width:0;" /></a></td><td class="ctl00_TreeView1_2" onmouseover="TreeView_HoverNode(ctl00_TreeView1_Data, this)" onmouseout="TreeView_UnhoverNode(this)" style="white-space:nowrap;"><a class="ctl00_TreeView1_0 ctl00_TreeView1_1" href="../adminmenu.aspx" id="ctl00_TreeView1t4">Admin</a></td>
                        </tr><tr style="height:0px;">
                              <td></td>
                        </tr>
                  </table>
            </div><table cellpadding="0" cellspacing="0" style="border-width:0;">
                  <tr style="height:0px;">
                        <td></td>
                  </tr><tr>
                        <td><div style="width:15px;height:1px"></div></td><td><img src="/Dev/WebResource.axd?d=b59ugrze69gFOlWrsTJRBvZVcC7tXFDhEHfixbHutoptPjWsga1qNdYShuP0e_vQ0&amp;t=632826895366249935" alt="" /></td><td><a href="javascript:__doPostBack('ctl00$TreeView1','sApplications\\Asset Verification')" onclick="TreeView_SelectNode(ctl00_TreeView1_Data, this,'ctl00_TreeView1t5');" id="ctl00_TreeView1t5i"><img src="/Dev/WebResource.axd?d=b59ugrze69gFOlWrsTJRBkZTwTSz80oVog6LfWZeI2SbNRdwZGDBKCdSx6S-Nhbq0&amp;t=632826895366249935" alt="" style="border-width:0;" /></a></td><td class="ctl00_TreeView1_2" onmouseover="TreeView_HoverNode(ctl00_TreeView1_Data, this)" onmouseout="TreeView_UnhoverNode(this)" style="white-space:nowrap;"><a class="ctl00_TreeView1_0 ctl00_TreeView1_1" href="javascript:__doPostBack('ctl00$TreeView1','sApplications\\Asset Verification')" onclick="TreeView_SelectNode(ctl00_TreeView1_Data, this,'ctl00_TreeView1t5');" id="ctl00_TreeView1t5">Asset Verification</a></td>
                  </tr><tr style="height:0px;">
                        <td></td>
                  </tr>
            </table>
      </div><table cellpadding="0" cellspacing="0" style="border-width:0;">
            <tr style="height:0px;">
                  <td></td>
            </tr><tr>
                  <td><img src="/Dev/WebResource.axd?d=b59ugrze69gFOlWrsTJRBvZVcC7tXFDhEHfixbHutoptPjWsga1qNdYShuP0e_vQ0&amp;t=632826895366249935" alt="" /></td><td><a id="ctl00_TreeView1t6i"><img src="/Dev/WebResource.axd?d=b59ugrze69gFOlWrsTJRBkZTwTSz80oVog6LfWZeI2SbNRdwZGDBKCdSx6S-Nhbq0&amp;t=632826895366249935" alt="" style="border-width:0;" /></a></td><td class="ctl00_TreeView1_2" onmouseover="TreeView_HoverNode(ctl00_TreeView1_Data, this)" onmouseout="TreeView_UnhoverNode(this)" style="white-space:nowrap;"><a class="ctl00_TreeView1_0 ctl00_TreeView1_1" id="ctl00_TreeView1t6">Software</a></td>
            </tr><tr style="height:0px;">
                  <td></td>
            </tr>
      </table><table cellpadding="0" cellspacing="0" style="border-width:0;">
            <tr style="height:0px;">
                  <td></td>
            </tr><tr>
                  <td><img src="/Dev/WebResource.axd?d=b59ugrze69gFOlWrsTJRBvZVcC7tXFDhEHfixbHutoptPjWsga1qNdYShuP0e_vQ0&amp;t=632826895366249935" alt="" /></td><td><a id="ctl00_TreeView1t7i"><img src="/Dev/WebResource.axd?d=b59ugrze69gFOlWrsTJRBkZTwTSz80oVog6LfWZeI2SbNRdwZGDBKCdSx6S-Nhbq0&amp;t=632826895366249935" alt="" style="border-width:0;" /></a></td><td class="ctl00_TreeView1_2" onmouseover="TreeView_HoverNode(ctl00_TreeView1_Data, this)" onmouseout="TreeView_UnhoverNode(this)" style="white-space:nowrap;"><a class="ctl00_TreeView1_0 ctl00_TreeView1_1" id="ctl00_TreeView1t7">Network</a></td>
            </tr><tr style="height:0px;">
                  <td></td>
            </tr>
      </table><table cellpadding="0" cellspacing="0" style="border-width:0;">
            <tr style="height:0px;">
                  <td></td>
            </tr><tr>
                  <td><a id="ctl00_TreeView1n8" href="javascript:TreeView_ToggleNode(ctl00_TreeView1_Data,8,ctl00_TreeView1n8,' ',ctl00_TreeView1n8Nodes)"><img src="/Dev/WebResource.axd?d=b59ugrze69gFOlWrsTJRBgNVlyAJAHCqeG-8XMFdD3rGUMQTuUppu1UgAzALMNzg0&amp;t=632826895366249935" alt="Expand Access Databases" style="border-width:0;" /></a></td><td><a href="javascript:TreeView_ToggleNode(ctl00_TreeView1_Data,8,ctl00_TreeView1n8,' ',ctl00_TreeView1n8Nodes)" id="ctl00_TreeView1t8i"><img src="../AccessTemplate%5B1%5D.gif" alt="" style="border-width:0;" /></a></td><td class="ctl00_TreeView1_2" onmouseover="TreeView_HoverNode(ctl00_TreeView1_Data, this)" onmouseout="TreeView_UnhoverNode(this)" style="white-space:nowrap;"><a class="ctl00_TreeView1_0 ctl00_TreeView1_1" href="javascript:TreeView_ToggleNode(ctl00_TreeView1_Data,8,ctl00_TreeView1n8,' ',ctl00_TreeView1n8Nodes)" id="ctl00_TreeView1t8">Access Databases</a></td>
            </tr><tr style="height:0px;">
                  <td></td>
            </tr>
      </table><div id="ctl00_TreeView1n8Nodes" style="display:none;">
            <table cellpadding="0" cellspacing="0" style="border-width:0;">
                  <tr style="height:0px;">
                        <td></td>
                  </tr><tr>
                        <td><div style="width:15px;height:1px"></div></td><td><a id="ctl00_TreeView1n9" href="javascript:TreeView_ToggleNode(ctl00_TreeView1_Data,9,ctl00_TreeView1n9,' ',ctl00_TreeView1n9Nodes)"><img src="/Dev/WebResource.axd?d=b59ugrze69gFOlWrsTJRBgNVlyAJAHCqeG-8XMFdD3rGUMQTuUppu1UgAzALMNzg0&amp;t=632826895366249935" alt="Expand Business Units" style="border-width:0;" /></a></td><td><a href="javascript:TreeView_ToggleNode(ctl00_TreeView1_Data,9,ctl00_TreeView1n9,' ',ctl00_TreeView1n9Nodes)" title="Forms and Reports for your specific Business Unit" id="ctl00_TreeView1t9i"><img src="/Dev/WebResource.axd?d=b59ugrze69gFOlWrsTJRBpyjAtyWgUX6aL4TwHXfx29r0ecVaA_hCE3_vMdS1yFt0&amp;t=632826895366249935" alt="" style="border-width:0;" /></a></td><td class="ctl00_TreeView1_2 ctl00_TreeView1_4" onmouseover="TreeView_HoverNode(ctl00_TreeView1_Data, this)" onmouseout="TreeView_UnhoverNode(this)" style="white-space:nowrap;"><a class="ctl00_TreeView1_0 ctl00_TreeView1_1 ctl00_TreeView1_3" href="javascript:TreeView_ToggleNode(ctl00_TreeView1_Data,9,ctl00_TreeView1n9,' ',ctl00_TreeView1n9Nodes)" title="Forms and Reports for your specific Business Unit" id="ctl00_TreeView1t9">Business Units</a></td>
                  </tr><tr style="height:0px;">
                        <td></td>
                  </tr>
            </table><div id="ctl00_TreeView1n9Nodes" style="display:none;">
                  <table cellpadding="0" cellspacing="0" style="border-width:0;">
                        <tr style="height:0px;">
                              <td></td>
                        </tr><tr>
                              <td><div style="width:15px;height:1px"></div></td><td><div style="width:15px;height:1px"></div></td><td><img src="/Dev/WebResource.axd?d=b59ugrze69gFOlWrsTJRBvZVcC7tXFDhEHfixbHutoptPjWsga1qNdYShuP0e_vQ0&amp;t=632826895366249935" alt="" /></td><td><a href="Access_Edit.aspx" id="ctl00_TreeView1t10i"><img src="/Dev/WebResource.axd?d=b59ugrze69gFOlWrsTJRBkZTwTSz80oVog6LfWZeI2SbNRdwZGDBKCdSx6S-Nhbq0&amp;t=632826895366249935" alt="" style="border-width:0;" /></a></td><td class="ctl00_TreeView1_2" onmouseover="TreeView_HoverNode(ctl00_TreeView1_Data, this)" onmouseout="TreeView_UnhoverNode(this)" style="white-space:nowrap;"><a class="ctl00_TreeView1_0 ctl00_TreeView1_1" href="Access_Edit.aspx" id="ctl00_TreeView1t10">Update Database Information</a></td>
                        </tr><tr style="height:0px;">
                              <td></td>
                        </tr>
                  </table><table cellpadding="0" cellspacing="0" style="border-width:0;">
                        <tr style="height:0px;">
                              <td></td>
                        </tr><tr>
                              <td><div style="width:15px;height:1px"></div></td><td><div style="width:15px;height:1px"></div></td><td><img src="/Dev/WebResource.axd?d=b59ugrze69gFOlWrsTJRBvZVcC7tXFDhEHfixbHutoptPjWsga1qNdYShuP0e_vQ0&amp;t=632826895366249935" alt="" /></td><td><a href="Access_Add.aspx" id="ctl00_TreeView1t11i"><img src="/Dev/WebResource.axd?d=b59ugrze69gFOlWrsTJRBkZTwTSz80oVog6LfWZeI2SbNRdwZGDBKCdSx6S-Nhbq0&amp;t=632826895366249935" alt="" style="border-width:0;" /></a></td><td class="ctl00_TreeView1_2" onmouseover="TreeView_HoverNode(ctl00_TreeView1_Data, this)" onmouseout="TreeView_UnhoverNode(this)" style="white-space:nowrap;"><a class="ctl00_TreeView1_0 ctl00_TreeView1_1" href="Access_Add.aspx" id="ctl00_TreeView1t11">Add New Databases</a></td>
                        </tr><tr style="height:0px;">
                              <td></td>
                        </tr>
                  </table>
            </div>
      </div>
</div><a id="ctl00_TreeView1_SkipLink"></a>
                </td>
                <td style="width: 100%; position: relative; height: 143px;" valign="top">
                   
    <span id="ctl00_ContentPlaceHolder2_Label4" style="display:inline-block;border-width:0px;font-family:Tahoma;font-size:10pt;font-weight:bold;">Assets for </span>&nbsp;
    <span id="ctl00_ContentPlaceHolder2_DataList1" style="display:inline-block;color:Blue;border-width:0px;font-family:Tahoma;font-size:10pt;font-weight:bold;height:1px;"><span>
            <span id="ctl00_ContentPlaceHolder2_DataList1_ctl00_firstNameLabel">Anthony</span>
            <span id="ctl00_ContentPlaceHolder2_DataList1_ctl00_lastNameLabel">Cancel</span>
            (<span id="ctl00_ContentPlaceHolder2_DataList1_ctl00_Label3">U17211</span>)
        </span></span>
   
   
    <br />
    <br />
    <table cellspacing="0" border="0" id="ctl00_ContentPlaceHolder2_FormView1" style="border-width:0px;border-style:None;width:688px;border-collapse:collapse;">

</table>
    <br />
   
    <span id="ctl00_ContentPlaceHolder2_Label1" style="display:inline-block;font-family:Tahoma;font-size:8pt;height:24px;width:688px;">To update the information below, please click on the Edit link then update the respective data. Once you are done updating the data, click on the Update link to the left of the User column to save your changes.</span><span style="font-size: 10pt;
            font-family: Tahoma">
    <br />
    <br />
        </span>
    <span id="ctl00_ContentPlaceHolder2_Label2" style="display:inline-block;font-family:Tahoma;font-size:8pt;height:32px;width:688px;">Once you have verified your assets, please click on the Submit Verified Assets button. Please note that once you submit your verified assets you will not be able to make any changes to them unless you call the helpdesk.</span><span style="font-size: 10pt;
            font-family: Tahoma">
    <br />
        </span>
   

                </td>
            </tr>
            <tr style="font-size: 12pt">
                <td align="left" colspan="2" style="width: 100%; position: static; height: 100%"
                    valign="top">
       
    <table border="0" cellpadding="0" cellspacing="0">
        <tr>
            <td>
    <div>
      <table cellspacing="0" cellpadding="4" align="Left" border="0" id="ctl00_ContentPlaceHolder1_GridView1" style="color:#333333;font-size:8pt;height:112px;width:920px;border-collapse:collapse;font-family: Tahoma">
            <tr style="color:White;background-color:#5D7B9D;font-weight:bold;">
                  <th scope="col">&nbsp;</th><th scope="col"><a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$GridView1','Sort$username')" style="color:White;">User</a></th><th scope="col"><a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$GridView1','Sort$asset_tag')" style="color:White;">Asset Tag</a></th><th scope="col"><a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$GridView1','Sort$model_description')" style="color:White;">Asset Type</a></th><th scope="col">Target Asset Type</th><th scope="col">Primary Prod Computer</th><th scope="col">Justification Comment</th><th scope="col">Other Comments</th>
            </tr><tr style="color:#333333;background-color:#999999;">
                  <td><a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$GridView1$ctl02$ctl00','')" style="color:#333333;">Update</a>&nbsp;<a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$GridView1','Cancel$0')" style="color:#333333;">Cancel</a></td><td>U17211</td><td>59599</td><td><input name="ctl00$ContentPlaceHolder1$GridView1$ctl02$ctl02" type="text" value="Desktop" title="Asset Type" /></td><td>
            <select name="ctl00$ContentPlaceHolder1$GridView1$ctl02$TargetComputerTypeDropDownlist" id="ctl00_ContentPlaceHolder1_GridView1_ctl02_TargetComputerTypeDropDownlist">
                        <option selected="selected" value="Desktop">Desktop</option>

                  </select>
            </td><td>
            <select name="ctl00$ContentPlaceHolder1$GridView1$ctl02$PrimaryProductivityComputerDropDownlist" id="ctl00_ContentPlaceHolder1_GridView1_ctl02_PrimaryProductivityComputerDropDownlist">
                        <option selected="selected" value="y">y</option>
                        <option value="n">n</option>

                  </select>
            </td><td>
            <select name="ctl00$ContentPlaceHolder1$GridView1$ctl02$JustificationCommentDropDownlist" id="ctl00_ContentPlaceHolder1_GridView1_ctl02_JustificationCommentDropDownlist">
                        <option value="My job requires travel outside Carpenter">My job requires travel outside Carpenter</option>
                        <option value="My job requires travel between Carpenter locations">My job requires travel between Carpenter locations</option>
                        <option value="I use my computer to give presentations">I use my computer to give presentations</option>
                        <option selected="selected" value="other">other</option>
                        <option value="Testing Computer">Testing Computer</option>
                        <option value="Development Computer">Development Computer</option>
                        <option value="Utility Computer">Utility Computer</option>
                        <option value="This computer must be refreshed">This computer must be refreshed</option>
                        <option value="other">other</option>
                        <option value="Please Select ...">Please Select ...</option>
                        <option value="Please select ...">Please select ...</option>

                  </select>
            </td><td>
                    <input name="ctl00$ContentPlaceHolder1$GridView1$ctl02$TextBox1" type="text" value="test" id="ctl00_ContentPlaceHolder1_GridView1_ctl02_TextBox1" />
                </td>
            </tr>
      </table>
</div>
            </td>
        </tr>
        <tr>
            <td style="width: 100px; text-indent: 200pt; position: static;
                text-align: left">
                <br />

    <input type="submit" name="ctl00$ContentPlaceHolder1$ButtonSubmit" value="Submit Verified Assets" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$ContentPlaceHolder1$ButtonSubmit&quot;, &quot;&quot;, false, &quot;&quot;, &quot;Assets_Targ_Edit.aspx&quot;, false, false))" id="ctl00_ContentPlaceHolder1_ButtonSubmit" /><br />
                <br />
   
       
     
                <br />
    </td>
        </tr>
    </table>

                </td>
            </tr>
        </table>
    </div>
   
<script type="text/javascript">
<!--
var ctl00_TreeView1_ImageArray =  new Array('/Dev/WebResource.axd?d=b59ugrze69gFOlWrsTJRBm4zqVuXmvhC4DMj08JPEkisclklYwxhcrxnEwJMBDUK0&t=632826895366249935', '/Dev/WebResource.axd?d=b59ugrze69gFOlWrsTJRBpyjAtyWgUX6aL4TwHXfx29r0ecVaA_hCE3_vMdS1yFt0&t=632826895366249935', '/Dev/WebResource.axd?d=b59ugrze69gFOlWrsTJRBkZTwTSz80oVog6LfWZeI2SbNRdwZGDBKCdSx6S-Nhbq0&t=632826895366249935', '/Dev/WebResource.axd?d=b59ugrze69gFOlWrsTJRBvZVcC7tXFDhEHfixbHutoptPjWsga1qNdYShuP0e_vQ0&t=632826895366249935', '/Dev/WebResource.axd?d=b59ugrze69gFOlWrsTJRBgNVlyAJAHCqeG-8XMFdD3rGUMQTuUppu1UgAzALMNzg0&t=632826895366249935', '/Dev/WebResource.axd?d=b59ugrze69gFOlWrsTJRBvJPM3xG05jNibv9PIN1Rx0QIER8SUL0arXHF2C1o5XY0&t=632826895366249935');
// -->
</script>

<div>

      <input type="hidden" name="__VIEWSTATEENCRYPTED" id="__VIEWSTATEENCRYPTED" value="" />
      <input type="hidden" name="__PREVIOUSPAGE" id="__PREVIOUSPAGE" value="xVxRsogIH-CXu_HiNGWWizGN_UD7jgI9nIxu4B7fqmt4t9L17OKqc-uzRHinXpRq0" />
      <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="HT3+FzXq7mFntKuWQg0tRDJvAwcMBGi1qxtpLo5WmTEpNhW9Xx/W25vnQN5ZY7RRvJVv7tZ4t2aTdZWEi+ZlRn4OYxca/hfoPTWbJIc3GbvYuxPN7R6UtmGkCHNMyVo70aEAQ6g87CgNMGT5BbxwwKQUR6naHBwZ4sn/Smvxoeo/b4rjy4G5XJhIFVncfX31c9PW6yMFuD5vzgf0vkgKsA==" />
</div>

<script type="text/javascript">
<!--

WebForm_InitCallback();var ctl00_TreeView1_Data = new Object();
ctl00_TreeView1_Data.images = ctl00_TreeView1_ImageArray;
ctl00_TreeView1_Data.collapseToolTip = "Collapse {0}";
ctl00_TreeView1_Data.expandToolTip = "Expand {0}";
ctl00_TreeView1_Data.expandState = theForm.elements['ctl00_TreeView1_ExpandState'];
ctl00_TreeView1_Data.selectedNodeID = theForm.elements['ctl00_TreeView1_SelectedNode'];
ctl00_TreeView1_Data.hoverClass = 'ctl00_TreeView1_8';
ctl00_TreeView1_Data.hoverHyperLinkClass = 'ctl00_TreeView1_7';
for (var i=0;i<6;i++) {
var preLoad = new Image();
if (ctl00_TreeView1_ImageArray[i].length > 0)
preLoad.src = ctl00_TreeView1_ImageArray[i];
}
ctl00_TreeView1_Data.lastIndex = 12;
ctl00_TreeView1_Data.populateLog = theForm.elements['ctl00_TreeView1_PopulateLog'];
ctl00_TreeView1_Data.treeViewID = 'ctl00$TreeView1';
ctl00_TreeView1_Data.name = 'ctl00_TreeView1_Data';
// -->
</script>
</form>
</body>
</html>


0
 
LVL 4

Expert Comment

by:gregg1ep00
ID: 16953296
Can you also post the aspx code for your gridview?
0
 

Author Comment

by:acancel
ID: 16953374
sure...


here is the aspx code

<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Assets_Targ_Edit.aspx.vb" Inherits="Assets_Targ_Edit" title="Asset Targeting" AspCompat = "True"  %>
<%@ MasterType VirtualPath="~/MasterPage.master" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
    <asp:Label ID="Label4" runat="server" BorderWidth="0px"
        Font-Bold="True" Font-Names="Tahoma" Font-Size="10pt"
        Text="Assets for "></asp:Label>&nbsp;
    <asp:DataList ID="DataList1" runat="server" DataKeyField="userId"
        DataSourceID="AccessDataSource1" Font-Bold="True"
        Font-Names="Tahoma" Font-Size="10pt" ForeColor="Blue"
        Height="1px" RepeatLayout="Flow" BorderWidth="0px" CellPadding="0">
        <ItemTemplate>
            <asp:Label ID="firstNameLabel" runat="server" Text='<%# Eval("firstName") %>'></asp:Label>
            <asp:Label ID="lastNameLabel" runat="server" Text='<%# Eval("lastName") %>'></asp:Label>
            (<asp:Label ID="Label3" runat="server" Text='<%# Eval("userId") %>'></asp:Label>)
        </ItemTemplate>
    </asp:DataList>
    <asp:Label ID="userid2" runat="server" Font-Names="Tahoma"
        Font-Size="10pt" Text="Label" Visible="False"></asp:Label>
    <asp:AccessDataSource ID="AccessDataSource1" runat="server"
        DataFile="~/App_Data/Access Conversion.mdb" SelectCommand="SELECT * FROM [AC_CAR_Users_With_Email] WHERE ([userId] = ?)">
        <SelectParameters>
            <asp:ControlParameter ControlID="userid2" Name="userId"
                PropertyName="Text" Type="String" />
        </SelectParameters>
    </asp:AccessDataSource>
    <br />
    <br />
    <asp:FormView ID="FormView1" runat="server" BorderStyle="None"
        BorderWidth="0px" DataKeyNames="comm_id" DataSourceID="ct_target_comm_text"
        Width="688px">
        <EditItemTemplate>
            comm_id:
            <asp:Label ID="comm_idLabel1" runat="server" Text='<%# Eval("comm_id") %>'>
            </asp:Label><br />
            comm_number:
            <asp:TextBox ID="comm_numberTextBox" runat="server"
                Text='<%# Bind("comm_number") %>'>
            </asp:TextBox><br />
            comm_text:
            <asp:TextBox ID="comm_textTextBox" runat="server" Text='<%# Bind("comm_text") %>'>
            </asp:TextBox><br />
            <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True"
                CommandName="Update" Text="Save"  ForeColor="GhostWhite">
            </asp:LinkButton>
            <asp:LinkButton ID="UpdateCancelButton" runat="server"
                CausesValidation="False" CommandName="Cancel" Text="Cancel">
            </asp:LinkButton>
        </EditItemTemplate>
        <InsertItemTemplate>
            comm_number:
            <asp:TextBox ID="comm_numberTextBox" runat="server"
                Text='<%# Bind("comm_number") %>'>
            </asp:TextBox><br />
            comm_text:
            <asp:TextBox ID="comm_textTextBox" runat="server" Text='<%# Bind("comm_text") %>'>
            </asp:TextBox><br />
            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True"
                CommandName="Insert" Text="Insert">
            </asp:LinkButton>
            <asp:LinkButton ID="InsertCancelButton" runat="server"
                CausesValidation="False" CommandName="Cancel" Text="Cancel">
            </asp:LinkButton>
        </InsertItemTemplate>
        <ItemTemplate>
            <asp:Label ID="comm_textLabel" runat="server" Font-Names="Tahoma"
                Font-Size="8pt" Text='<%# Bind("comm_text") %>'></asp:Label><br />
        </ItemTemplate>
    </asp:FormView>
    <br />
    <asp:SqlDataSource ID="ct_target_comm_text" runat="server"
        ConnectionString="<%$ ConnectionStrings:PCRefreshConnectionString %>"
        SelectCommand="SELECT * FROM [ct_asset_target_comm_text] WHERE ([comm_number] = @comm_number)">
        <SelectParameters>
            <asp:ControlParameter ControlID="CommTextBox" Name="comm_number"
                PropertyName="Text" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:Label ID="Label1" runat="server" Font-Names="Tahoma"
        Font-Size="8pt" Height="24px" Text="To update the information below, please click on the Edit link then update the respective data. Once you are done updating the data, click on the Update link to the left of the User column to save your changes."
        Width="688px"></asp:Label><span style="font-size: 10pt;
            font-family: Tahoma">
    <br />
    <br />
        </span>
    <asp:Label ID="Label2" runat="server" Font-Names="Tahoma"
        Font-Size="8pt" Height="32px" Text="Once you have verified your assets, please click on the Submit Verified Assets button. Please note that once you submit your verified assets you will not be able to make any changes to them unless you call the helpdesk."
        Width="688px"></asp:Label><span style="font-size: 10pt;
            font-family: Tahoma">
    <br />
        </span>
    <asp:TextBox ID="CommTextBox" runat="server" Visible="False"></asp:TextBox>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <table border="0" cellpadding="0" cellspacing="0">
        <tr>
            <td>
    <asp:GridView ID="GridView1"
        runat="server"
        AllowPaging="True"
        AllowSorting="True"
        AutoGenerateColumns="False"
        CellPadding="4"
        DataKeyNames="ct_asset_target_id"
        onrowediting="GridView1_RowEditing"
        DataSourceID="ct_asset_targeting"
        EmptyDataText='"Your department either does not have any databases assigned to it or you do not have permission to view the data." '
        Font-Size="8pt"
        ForeColor="#333333"
        GridLines="None"
        Height="112px"
        HorizontalAlign="Left"
        Style="font-family: Tahoma"
        Width="920px">
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <Columns>
            <asp:CommandField ShowEditButton="True" />
            <asp:BoundField DataField="username" HeaderText="User"
                SortExpression="username" ReadOnly="True" />
            <asp:BoundField DataField="asset_tag" HeaderText="Asset Tag"
                SortExpression="asset_tag" ReadOnly="True" />
            <asp:BoundField DataField="model_description" HeaderText="Asset Type"
                SortExpression="model_description" />
             
             <asp:TemplateField HeaderText ="Target Asset Type" ConvertEmptyStringToNull="False">
            <ItemTemplate >
               <asp:label ID="label_target_asset_type" text='<%# Eval("target_computer_type") %> ' runat ="server" />
            </ItemTemplate>
            <EditItemTemplate >
            <asp:DropDownList ID="TargetComputerTypeDropDownlist"  runat ="server"
                DataSourceID = "SqlDataSource3"
                Datatextfield ="model_description"
                DataValueField ="model_description"
                SelectedValue= '<%#Bind("target_computer_type") %>'>
            </asp:DropDownList>
            </EditItemTemplate>          
            </asp:TemplateField>
           
            <asp:TemplateField HeaderText ="Primary Prod Computer" ConvertEmptyStringToNull="False">
            <ItemTemplate >
                <asp:label ID="label_primary_productivity_computerd" text='<%# Bind("primary_productivity_computer") %> ' runat ="server" />
            </ItemTemplate>
            <EditItemTemplate >
            <asp:DropDownList ID="PrimaryProductivityComputerDropDownlist"  runat ="server"
                DataSourceID = "SqlDataSource2"
                Datatextfield ="ct_Literal"
                DataValueField ="ct_Literal"
                SelectedValue= '<%#Bind("primary_productivity_computer") %>' >
            </asp:DropDownList>
            </EditItemTemplate>          
            </asp:TemplateField>
           
            <asp:TemplateField HeaderText ="Justification Comment" ConvertEmptyStringToNull="False">
            <ItemTemplate >
               <asp:label ID="label_justification_comments" text='<%# Bind("justification_comment") %> ' runat ="server" />
            </ItemTemplate>
            <EditItemTemplate >
            <asp:DropDownList ID="JustificationCommentDropDownlist"  runat ="server"
                DataSourceID = "SqlDataSource1"
                Datatextfield ="justification_comment"
                DataValueField ="justification_comment"
                SelectedValue= '<%#Bind("justification_comment") %>'>
            </asp:DropDownList>
            </EditItemTemplate>          
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Other Comments">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("justification_comment_other") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("justification_comment_other") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
           
        </Columns>
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        <EditRowStyle BackColor="#999999" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True"
            ForeColor="White" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
    </asp:GridView>
            </td>
        </tr>
        <tr>
            <td style="width: 100px; text-indent: 200pt; position: static;
                text-align: left">
                <br />

    <asp:Button ID="ButtonSubmit" runat="server" Text="Submit Verified Assets" PostBackUrl="~/BusinessUnits/Assets_Targ_Edit.aspx" /><br />
                <br />
    <asp:SqlDataSource ID="ct_asset_targeting" runat="server"
        ConnectionString="<%$ ConnectionStrings:PCRefreshConnectionString %>"
        DeleteCommand="DELETE FROM [ct_asset_target] WHERE [ct_asset_target_id] = @ct_asset_target_id"
        InsertCommand="INSERT INTO [ct_asset_target] ([aggr_dept_id], [username], [asset_tag], [model_description], [target_computer_type], [computer_name], [mail_cd], [asset_function], [network_connected], [local_printer_attached], [primary_productivity_computer], [justification_comment], [justification_comment_other], [last_change_date], [last_change_user], [pc_refresh_status]) VALUES (@aggr_dept_id, @username, @asset_tag, @model_description, @target_computer_type, @computer_name, @mail_cd, @asset_function, @network_connected, @local_printer_attached, @primary_productivity_computer, @justification_comment, @justification_comment_other, @last_change_date, @last_change_user, @pc_refresh_status)"
        SelectCommand="SELECT ct_asset_target_id, username, asset_tag, target_computer_type, primary_productivity_computer, justification_comment, justification_comment_other, last_change_date, last_change_user, pc_refresh_status, model_description, mail_cd FROM dbo.ct_asset_target WHERE (username = @Param1)"
        UpdateCommand="UPDATE dbo.ct_asset_target SET target_computer_type = @target_computer_type,primary_productivity_computer = @primary_productivity_computer, justification_comment = @justification_comment, justification_comment_other = @justification_comment_other, last_change_date = { fn NOW() }, last_change_user = @pUserID WHERE (ct_asset_target_id = @ct_asset_target_id)">
        <DeleteParameters>
            <asp:Parameter Name="ct_asset_target_id" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="target_computer_type" ConvertEmptyStringToNull="False"/>
            <asp:Parameter Name="primary_productivity_computer" Type="String" ConvertEmptyStringToNull="False" />
            <asp:Parameter Name="justification_comment" Type="String" />
            <asp:Parameter Name="justification_comment_other" Type="String" />
            <asp:ControlParameter ControlID="userid" DefaultValue="" Name="pUserID"  Type="String" />
            <asp:Parameter Name="ct_asset_target_id" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="aggr_dept_id" Type="String" />
            <asp:Parameter Name="username" Type="String" />
            <asp:Parameter Name="asset_tag" Type="String" />
            <asp:Parameter Name="model_description" Type="String" />
            <asp:Parameter Name="target_computer_type" Type="String" />
            <asp:Parameter Name="mail_cd" Type="String" />
            <asp:Parameter Name="asset_function" />
            <asp:Parameter Name="network_connected" />
            <asp:Parameter Name="local_printer_attached" />
            <asp:Parameter Name="primary_productivity_computer"  Type="String" />
            <asp:Parameter Name="justification_comment" Type="String" />
            <asp:Parameter Name="justification_comment_other" Type="String" />
            <asp:Parameter Name="last_change_date" Type="DateTime" />
            <asp:Parameter Name="last_change_user" Type="String" />
            <asp:Parameter Name="pc_refresh_status" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="userid" Name="Param1"
                PropertyName="Text" />
        </SelectParameters>
    </asp:SqlDataSource>
       <asp:SqlDataSource ID="SqlDataSource2" runat="server"
        ConnectionString="<%$ ConnectionStrings:PCRefreshConnectionString %>"
        SelectCommand="SELECT [ct_literal] FROM [ct_literals] WHERE ([ct_literal_id] <= @ct_literal_id)">
        <SelectParameters>
            <asp:Parameter DefaultValue="2" Name="ct_literal_id"
                Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource3" runat="server"
        ConnectionString="<%$ ConnectionStrings:PCRefreshConnectionString %>"
        SelectCommand="SELECT DISTINCT model_description, username FROM dbo.ct_asset_target WHERE (username = @Param1)">
        <SelectParameters>
            <asp:ControlParameter ControlID="userid" Name="Param1"
                PropertyName="Text" />
        </SelectParameters>
    </asp:SqlDataSource> <asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:PCRefreshConnectionString %>"
        SelectCommand="SELECT justification_comment FROM dbo.ct_asset_target_justification">
    </asp:SqlDataSource>
                <br />
    <asp:Label ID="userid" runat="server" Font-Names="Tahoma"
        Font-Size="10pt" Text="Label" Visible="False"></asp:Label></td>
        </tr>
    </table>
</asp:Content>

0
 
LVL 4

Expert Comment

by:gregg1ep00
ID: 16953483
Ok, I've tested this on my system and it works.  Hopefully you can adapt it to your situation.  My VB syntax may be off, so please double check me!

First, put your stuff from RowEditing into RowDataBound.  I think, in your case, it would be something like:

Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound

      If e.Row.RowState = DataControlRowState.Edit Then
            Dim sAsset As String = e.Row.Cells(3).Text
            Dim sJustification As TextBox = CType(e.Row.FindControl("TextBox1"), TextBox)

            If sAsset = "Desktop" Then
                  sJustification.ReadOnly = True
            End If
      End If
End Sub

Add the event handler to your aspx page:
<asp:GridView ID="GridView1" runat="server" OnRowDataBound="GridView1_RowDataBound">
0
 
LVL 4

Accepted Solution

by:
gregg1ep00 earned 500 total points
ID: 16953540
Also, instead of getting the asset tag like this, in the RowDataBound handler, do this instead (it's a little cleaner):

Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound

     If e.Row.RowState = DataControlRowState.Edit Then
          Dim oData As DataRowView = CType(e.Row.DataItem, DataRowView)

          Dim sAsset As String = oData("asset_tag").ToString()
          Dim sJustification As TextBox = CType(e.Row.FindControl("TextBox1"), TextBox)

          If sAsset = "Desktop" Then
               sJustification.ReadOnly = True
          End If
     End If
End Sub

Hope this helps!  ;)
Greg
0
 

Author Comment

by:acancel
ID: 16953622
Gregg

You are the man....thanks a million....you have saved my behind
0
 

Author Comment

by:acancel
ID: 16953908
spoke to soon

when I have a laptop in the 1st record and a desktop in the second record, the fields stay enabled. Any ideas why? Is the row index not being captured?
0
 

Author Comment

by:acancel
ID: 16954046
when i debug, it looks like e.Row.RowState is being set to 5 for whatever reason while DataControlRowState.Edit is 4. This only happens on the second record. The first record equals and enters into the if statement
0
 
LVL 4

Expert Comment

by:gregg1ep00
ID: 16954232
Let me make sure I understand correctly.  You have a laptop in the 1st record and a desktop in the 2nd record.  When you edit the 2nd item, the TextBox is still enabled?  What about when you edit the 1st item?

I'm not sure what's going on with the RowState, but try this instead.  In the RowDataBound() method:

If (e.Row.RowType = DataControlRowType.DataRow) & (e.Row.RowIndex = DataGrid1.EditItemIndex) Then
          Dim oData As DataRowView = CType(e.Row.DataItem, DataRowView)

          Dim sAsset As String = oData("asset_tag").ToString()
          Dim sJustification As TextBox = CType(e.Row.FindControl("TextBox1"), TextBox)

          If sAsset = "Desktop" Then
               sJustification.ReadOnly = True
          End If
End If
0
 

Author Comment

by:acancel
ID: 16954401
that is correct. The fields do not get disabled with either record, even if I change the asset type to desktop for the 1st record

      User     Asset  Type       Target   Pr Justification Comment                            Other Comments
Edit U17211 61660 Desktop  Desktop  y  My job requires travel outside work
Edit U17211 59599 Desktop  Desktop  y  I use my computer to give presentations  tes  

I tried your code but it seems that is for a datagrid, this is a gridview. It stated edititemindex is not part of gridview arguments
0
 

Author Comment

by:acancel
ID: 16954437
ok, it seemed that the previous combo of a laptop and desktop remained within the viewstate and hence why the 1st row also not disabling. So after refreshing the data, the first row with a desktop does in fact disable the fields, but the second row still does not. Could there be some sort of posting or chaching that is not being done or being updated
0
 
LVL 4

Expert Comment

by:gregg1ep00
ID: 16954542
Sorry, I meant EditIndex, not EditItemIndex.  So:

If (e.Row.RowType = DataControlRowType.DataRow) & (e.Row.RowIndex = DataGrid1.EditIndex) Then
          Dim oData As DataRowView = CType(e.Row.DataItem, DataRowView)

          Dim sAsset As String = oData("asset_tag").ToString()
          Dim sJustification As TextBox = CType(e.Row.FindControl("TextBox1"), TextBox)

          If sAsset = "Desktop" Then
               sJustification.ReadOnly = True
          End If
End If

See if that works.  :)
0
 

Author Comment

by:acancel
ID: 16954575
ok this is the error I get on line [If (e.Row.RowType = DataControlRowType.DataRow) & (e.Row.RowIndex = DataGrid1.EditIndex) Then
]

System.InvalidCastException was unhandled by user code
  Message="Conversion from string "FalseTrue" to type 'Boolean' is not valid."
  Source="Microsoft.VisualBasic"
  StackTrace:
       at Microsoft.VisualBasic.CompilerServices.Conversions.ToBoolean(String Value)
       at Assets_Targ_Edit.GridView1_RowDataBound(Object sender, GridViewRowEventArgs e) in C:\WebSites\Dev\BusinessUnits\Assets_Targ_Edit.aspx.vb:line 83
       at System.Web.UI.WebControls.GridViewRowEventHandler.Invoke(Object sender, GridViewRowEventArgs e)
       at System.Web.UI.WebControls.GridView.OnRowDataBound(GridViewRowEventArgs e)
       at System.Web.UI.WebControls.GridView.CreateRow(Int32 rowIndex, Int32 dataSourceIndex, DataControlRowType rowType, DataControlRowState rowState, Boolean dataBind, Object dataItem, DataControlField[] fields, TableRowCollection rows, PagedDataSource pagedDataSource)
       at System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding)
       at System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data)
       at System.Web.UI.WebControls.GridView.PerformDataBinding(IEnumerable data)
       at System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data)
       at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)
       at System.Web.UI.WebControls.DataBoundControl.PerformSelect()
       at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
       at System.Web.UI.WebControls.GridView.DataBind()
       at System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound()
       at System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls()
       at System.Web.UI.Control.EnsureChildControls()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Control.PreRenderRecursiveInternal()
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
0
 
LVL 4

Expert Comment

by:gregg1ep00
ID: 16954628
Sorry, my VB syntax is not very polished (I'm a C# dev).

Try this one:
If e.Row.RowType = DataControlRowType.DataRow Then
          If e.Row.RowIndex = DataGrid1.EditIndex Then
                    Dim oData As DataRowView = CType(e.Row.DataItem, DataRowView)

                    Dim sAsset As String = oData("asset_tag").ToString()
                    Dim sJustification As TextBox = CType(e.Row.FindControl("TextBox1"), TextBox)

                    If sAsset = "Desktop" Then
                         sJustification.ReadOnly = True
                    End If
          End If
End If
0
 

Author Comment

by:acancel
ID: 16954682
Actually, i just changed you "&" to And and it worked great. I seemd to be good right now, however I may need some more assistance as i will need to populate some of those justifications depending on their asset. I will open another question and email you once I post the issues. Thank again for all your help
0
 
LVL 4

Expert Comment

by:gregg1ep00
ID: 16954732
Yeah, I don't really know the VB syntax all too well.  As I was typing this stuff out, I was trying to figure out how to write it in VB using MSDN.

Glad you got it working!  Let me know if you need anything else.

Greg
0
 

Author Comment

by:acancel
ID: 16955121
greg

just asked another question (Filter 1 DropDownList With Selection of Another DropDownList within a gridview). Seems pretty straight forward but your help is appreciated, thanks
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video discusses moving either the default database or any database to a new volume.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now