Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

gridview selected index changed to fire new gridview on same page

Status
Not open for further replies.

ktb916

Programmer
Jan 22, 2004
76
US
I've set up to GridViews on my page - 1 receives a parameter from a previously clicked page the other receives a parameter from the first GridView when a row is selected. The second one does not work. I think the reason is I do not have a mechanism for firing the data source for the second GridView. I need the code that would go in the [GridView1_SelectedIndexChanged] routine. I have a parameter set up for the second GridView I think I just need a way to rebind the datasource:
Code:
 <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:EMINConnectionString %>"
            SelectCommand="SELECT SOPNUMBE, ITEMNMBR, UNITPRCE, QUANTITY, UNITPRCE * QUANTITY AS ExtPrice FROM SOP10200 WHERE (SOPNUMBE = @SOPNUMBE)">
            <SelectParameters>
                <asp:ControlParameter ControlID="GridView1" DefaultValue="" Name="SOPNUMBE" PropertyName="SelectedValue" />
            </SelectParameters>
            
        </asp:SqlDataSource>

Thanks
 
Ok, so now I can get the data to show in the gridview - set the auto-regenerate columns to "True". But now I lose my data formatting. I want to be able to set 2 columns to currency and 1 to a fixed number. Can I add formatting at connection time?

Code:
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:EMINConnectionString %>"

Any help appreciated.
 
This is the problem when using any of the DataSource controls. You have limited control over then and cannot debug them. I suggest you get away from them and write the code yourself. This way, you will understand how to connect and retrieve/maniuplate data from a database. Also, you can debug your code if you have problems.
 
I agree it would be better to code it myself but I lack the skill. Do you have a suggestion for a video or tutorial that would help me get started?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top