gzieve
09-26-2005, 05:45 PM
I have a datagrid with bound columns. I want to select an item from a column and trigger that to fill some textboxes. This is my datagrid code on the html page.
<asp:datagrid id="DataGrid1" Width="272px" Height="32px" runat="server" OnSelectedIndexChanged="DataGrid1_Selection" BackColor="White" Font-Size="XX-Small" HorizontalAlign="Left" AutoGenerateColumns="False" Font-Names="Arial" BorderColor="#CC9999">
<selecteditemstyle backcolor="khaki"></selecteditemstyle>
<AlternatingItemStyle BackColor="#C0C0FF"></AlternatingItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#FFFFCC" BackColor="#8080FF"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="STUDY_CODE" HeaderText="STUDY CODE"></asp:BoundColumn>
<asp:BoundColumn DataField="START_DATE" HeaderText="MONITORING START DATE" DataFormatString="{0:MM/dd/yyyy}"></asp:BoundColumn>
<asp:BoundColumn DataField="END_DATE" HeaderText="MONITORING END DATE" DataFormatString="{0:MM/dd/yyyy}"></asp:BoundColumn>
<asp:BoundColumn DataField="PERCENT_ALLOCATION" HeaderText="PERCENT ALLOCATION"></asp:BoundColumn>
<asp:BoundColumn DataField="sites" HeaderText="SITES ASSIGNED"></asp:BoundColumn>
<asp:BoundColumn DataField="schedule" HeaderText="MONITORING SCHEDULE"></asp:BoundColumn>
</Columns>
</asp:datagrid>
This is my vb page code for the DataGrid1_Selection sub. I can't even get this far, so no idea if this is right or not.
Private Sub DataGrid1_Selection(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
TxtSites.Text = DataGrid1.SelectedItem.Cells(5).Text
TxtSchedules.Text = DataGrid1.SelectedItem.Cells(6).Text
End Sub
When I go to the page with the grid, I get a complilation error on the html page line with the "OnSelectedIndexChanged". What am I doing wrong? Thanks.
<asp:datagrid id="DataGrid1" Width="272px" Height="32px" runat="server" OnSelectedIndexChanged="DataGrid1_Selection" BackColor="White" Font-Size="XX-Small" HorizontalAlign="Left" AutoGenerateColumns="False" Font-Names="Arial" BorderColor="#CC9999">
<selecteditemstyle backcolor="khaki"></selecteditemstyle>
<AlternatingItemStyle BackColor="#C0C0FF"></AlternatingItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#FFFFCC" BackColor="#8080FF"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="STUDY_CODE" HeaderText="STUDY CODE"></asp:BoundColumn>
<asp:BoundColumn DataField="START_DATE" HeaderText="MONITORING START DATE" DataFormatString="{0:MM/dd/yyyy}"></asp:BoundColumn>
<asp:BoundColumn DataField="END_DATE" HeaderText="MONITORING END DATE" DataFormatString="{0:MM/dd/yyyy}"></asp:BoundColumn>
<asp:BoundColumn DataField="PERCENT_ALLOCATION" HeaderText="PERCENT ALLOCATION"></asp:BoundColumn>
<asp:BoundColumn DataField="sites" HeaderText="SITES ASSIGNED"></asp:BoundColumn>
<asp:BoundColumn DataField="schedule" HeaderText="MONITORING SCHEDULE"></asp:BoundColumn>
</Columns>
</asp:datagrid>
This is my vb page code for the DataGrid1_Selection sub. I can't even get this far, so no idea if this is right or not.
Private Sub DataGrid1_Selection(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
TxtSites.Text = DataGrid1.SelectedItem.Cells(5).Text
TxtSchedules.Text = DataGrid1.SelectedItem.Cells(6).Text
End Sub
When I go to the page with the grid, I get a complilation error on the html page line with the "OnSelectedIndexChanged". What am I doing wrong? Thanks.