|
-
Jan 13th, 2006, 09:53 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] Getting values from datagrid problem?
ny ideas how Ive broke this? It worked before but now I get this error
[ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index]
VB Code:
Private Sub dgNewCarriageBuildSheets_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgNewCarriageBuildSheets.UpdateCommand
'Declare variables
Dim txtGearMotor As TextBox
Dim txtRPM As TextBox
Dim dropHand As DropDownList
Dim txtPCB As TextBox
Dim txtMeggaTest As TextBox
Dim txtfTest As TextBox
Dim dropULTest As DropDownList
Dim txtsTest As TextBox
Dim calWEProd As Calendar
Dim dropModel As DropDownList
Dim txtSerialNo As TextBox
'Get the key value
[U] Main.objCarriageBuildSheet.PublicSerialNo = dgNewCarriageBuildSheets.DataKeys(e.Item.ItemIndex)[/U]
'Get other values from template columns
txtGearMotor = CType(e.Item.FindControl("txtMotorNo"), TextBox)
-
Jan 13th, 2006, 09:59 AM
#2
Re: Getting values from datagrid problem?
Did you set the datagrid's DataKeyField?
-
Jan 13th, 2006, 10:07 AM
#3
Thread Starter
Frenzied Member
Re: Getting values from datagrid problem?
TBH Mendhak It's friday, some annoying woman opposite me wont shutup gossiping and my heads about to expode and now stuffs suddenly going wrong all these things have lead to me forgetting what the bloody data key even is.
I must of had one once when it worked, perhaps i have deleted it later in the project should it be somewhere around here?
VB Code:
<div id="divPrint"><asp:datagrid id="dgNewCarriageBuildSheets" runat="server" Width="100%" AllowPaging="True" PageSize="15"
AutoGenerateColumns="False" BorderColor="Control" BorderWidth="1pt">
<SelectedItemStyle Font-Size="X-Small"></SelectedItemStyle>
<EditItemStyle Font-Size="X-Small"></EditItemStyle>
<AlternatingItemStyle Font-Size="Small" BackColor="Menu"></AlternatingItemStyle>
<ItemStyle Font-Size="Small"></ItemStyle>
<HeaderStyle Font-Size="X-Small" Font-Bold="True" ForeColor="Black" BackColor="Menu"></HeaderStyle>
<Columns>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update" CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn>
<asp:BoundColumn DataField="Lift Serial Number" ReadOnly="True" HeaderText="Serial No"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Motor Serial No">
<ItemTemplate>
<asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Gearmotor Serial Number") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="txtMotorNo" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Gearmotor Serial Number") %>'>
</asp:TextBox>
<asp:RequiredFieldValidator ControlToValidate="txtMotorNo" text="*" Runat="server" />
</EditItemTemplate>
</asp:TemplateColumn>
-
Jan 13th, 2006, 10:34 AM
#4
Thread Starter
Frenzied Member
Re: [RESOLVED] Getting values from datagrid problem?
Thanks Mendhak, after a crafty smoke sanity was restored and your tip off I realised the error of my ways, I must of deleted that line of code when attempting to neaten up my code earlier in the week.
VB Code:
'Bind grid to dataview
Private Sub BindGrid()
Main.objCarriageBuildSheet.GetBuilds()
Me.dgNewCarriageBuildSheets.DataSource = Main.objCarriageBuildSheet.vwCarriages
Me.dgNewCarriageBuildSheets.DataKeyField = "Lift Serial Number"
Me.dgNewCarriageBuildSheets.DataBind()
End Sub
-
Jan 13th, 2006, 11:27 AM
#5
Re: [RESOLVED] Getting values from datagrid problem?
You think you've got it bad? I've been listening to two of my coworkers talk about 'Celebrity Big Brother' for the past 5 hours. FIVE hours.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|