Click here to Skip to main content
16,005,178 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionHow do I reference a .wsc file in asp.net(c#) Pin
AF_Ciphr5-Sep-07 5:18
AF_Ciphr5-Sep-07 5:18 
QuestionAdding data into GridView Pin
haroon19805-Sep-07 4:59
haroon19805-Sep-07 4:59 
AnswerRe: Adding data into GridView Pin
orsini5-Sep-07 5:17
orsini5-Sep-07 5:17 
GeneralRe: Adding data into GridView Pin
haroon19805-Sep-07 5:51
haroon19805-Sep-07 5:51 
GeneralRe: Adding data into GridView Pin
orsini5-Sep-07 6:18
orsini5-Sep-07 6:18 
GeneralRe: Adding data into GridView Pin
haroon19805-Sep-07 22:42
haroon19805-Sep-07 22:42 
GeneralRe: Adding data into GridView Pin
orsini27-Sep-07 10:47
orsini27-Sep-07 10:47 
QuestionGridView with TextBoxes in HeaderRow for Search Pin
bspooner5-Sep-07 4:21
bspooner5-Sep-07 4:21 
I am trying to create a GridView with TextBoxes in the header that will allow searches. Here is the GridView:
<asp:GridView ID="gvSearchResults" runat="server" AutoGenerateColumns="false" EmptyDataText="No Records Found" OnRowCommand="gvSearchResults_RowCommand" ShowHeader="true">
 <Columns>
  <asp:BoundField DataField="CustomerCode" Visible="false" />
  <asp:BoundField DataField="CardNumber" HeaderText="Card Number"/>
  <asp:BoundField DataField="FirstName" HeaderText="First Name"/>
  <asp:BoundField DataField="MiddleInitial" HeaderText="Initial"/>
  <asp:BoundField DataField="LastName" HeaderText="Last Name"/>
  <asp:BoundField DataField="Address" HeaderText="Street"/>
  <asp:BoundField DataField="City" HeaderText="City"/>
  <asp:BoundField DataField="State" HeaderText="State"/>
  <asp:BoundField DataField="ZipCode" HeaderText="Zip Code"/>
  <asp:TemplateField>
   <HeaderTemplate>
    <asp:Button id="cmdSearch" CommandName="Search" Text="Search" runat="server"/>
   </HeaderTemplate>
   <ItemTemplate>
    <asp:Button id="cmdViewActivity" Text="Activity" CommandName="Activity" CommandArgument="CustomerCode" runat="server" />
    <asp:Button id="cmdViewDetails" Text="Details" CommandName="Details" CommandArgument="CustomerCode" runat="server" />
    </ItemTemplate>
   </asp:TemplateField>
 </Columns>
</asp:GridView>

Here is the code I am using to add a Label and TextBox to the header in Page_Load (when it is not a PostBack):
// create header for Card Number search
Label lblSearchCardNumber = new Label();
lblSearchCardNumber.Text = "Card Number<br />";
lblSearchCardNumber.CssClass = "headerlabel";
gvSearchResults.HeaderRow.Cells[1].Controls.Add(lblSearchCardNumber);
TextBox txtSearchCardNumber = new TextBox();
txtSearchCardNumber.Columns = 11;
txtSearchCardNumber.MaxLength = 11;
txtSearchCardNumber.CssClass = "headertextbox";
gvSearchResults.HeaderRow.Cells[1].Controls.Add(txtSearchCardNumber);

Everything works fine at this point (although I had to create a dummy DataSet to get the GridView to display initially). When the Search button is clicked I want to retrieve the values from the textboxes in the header to use as my search parameters. For some reason I cannot access the HeaderRow. What exactly am I doing wrong? I can access the Row information but not the HeaderRow?
protected void gvSearchResults_RowCommand(object sender, GridViewCommandEventArgs e)
    {
      if (e.CommandName == "Search")
        {
              // gather search parameters and perform the customer search
              string searchCardNumber = "";
              GridViewRow gvRow = gvSearchResults.HeaderRow;
              searchCardNumber = ((TextBox)gvRow.FindControl("txtSearchCardNumber")).Text;
        }
    }

AnswerRe: GridView with TextBoxes in HeaderRow for Search Pin
Imran Khan Pathan5-Sep-07 4:30
Imran Khan Pathan5-Sep-07 4:30 
GeneralRe: GridView with TextBoxes in HeaderRow for Search Pin
bspooner5-Sep-07 4:41
bspooner5-Sep-07 4:41 
GeneralRe: GridView with TextBoxes in HeaderRow for Search Pin
Imran Khan Pathan5-Sep-07 20:44
Imran Khan Pathan5-Sep-07 20:44 
GeneralRe: GridView with TextBoxes in HeaderRow for Search [modified] Pin
bspooner6-Sep-07 2:06
bspooner6-Sep-07 2:06 
AnswerRe: GridView with TextBoxes in HeaderRow for Search Pin
divyesh14325-Sep-07 4:54
divyesh14325-Sep-07 4:54 
GeneralRe: GridView with TextBoxes in HeaderRow for Search Pin
bspooner5-Sep-07 5:26
bspooner5-Sep-07 5:26 
QuestionAJAX problem Pin
marky7775-Sep-07 4:11
marky7775-Sep-07 4:11 
AnswerRe: AJAX problem Pin
Michael Sync5-Sep-07 16:37
Michael Sync5-Sep-07 16:37 
GeneralRe: AJAX problem Pin
marky7775-Sep-07 21:12
marky7775-Sep-07 21:12 
GeneralRe: AJAX problem Pin
marky7775-Sep-07 21:19
marky7775-Sep-07 21:19 
Questionproblem with dynamic gridview Please help Pin
orsini5-Sep-07 3:38
orsini5-Sep-07 3:38 
AnswerRe: problem with dynamic gridview Please help Pin
ToddHileHoffer5-Sep-07 3:47
ToddHileHoffer5-Sep-07 3:47 
GeneralRe: problem with dynamic gridview Please help Pin
orsini5-Sep-07 4:05
orsini5-Sep-07 4:05 
GeneralRe: problem with dynamic gridview Please help Pin
orsini5-Sep-07 4:07
orsini5-Sep-07 4:07 
GeneralRe: problem with dynamic gridview Please help Pin
ToddHileHoffer5-Sep-07 4:16
ToddHileHoffer5-Sep-07 4:16 
GeneralRe: problem with dynamic gridview Please help Pin
Imran Khan Pathan5-Sep-07 4:18
Imran Khan Pathan5-Sep-07 4:18 
GeneralRe: problem with dynamic gridview Please help Pin
orsini5-Sep-07 4:39
orsini5-Sep-07 4:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.