What if we take a route where all of your buttons call the same export method that determines which gridview to use, and then sends the appropriate datasource to your Excel creator? Not sure if it would be considered dirty, but it should be pretty easy, no custom controls involved.
Example:
Let's say we name all of our buttons something like this, so we can extract out their parent gridview
<asp:LinkButton ID="PeopleGridView_exportbutton" runat="server" onclick="excel_click" />
<asp:LinkButton ID="ShipmentsGridView_exportbutton" runat="server" onclick="excel_click" />
<asp:LinkButton ID="ProductsGridView_exportbutton" runat="server" onclick="excel_click" />
Now, we'll make that method:
protected void uxPrenatalSubmit_Click(object sender, EventArgs e){
string callerControlID = ((Control)sender).ID;
string gridveiwID = callerControlID.Replace("_exportbutton", "");
GridView gv = (GridView) findControl(gridveiwID);
myCustomExcelCreatorMethod(gv.DataSource); //your method thingie here
}
rlb.usa
2010-08-05 16:37:13