Forms Data Controls :: Code Sum Gridview By Category In 2.0?
Aug 26, 2010Code Sum gridview by category in asp.net 2.0
View 3 RepliesCode Sum gridview by category in asp.net 2.0
View 3 RepliesI am working in a project that is a musical website. I want to display the web page with all categories I have. In my database , named Category_Master, I have two fields like Category_Id (which is a primary key ) and Category_Name. I have generated category_Id with NEWID() function. The category_Id is not supposed to display on the web page. But, i have to select Category_Name and according to that , I have to get the category_Id. If I am using Static connection with SqlDataSource, i am able to make visible=false property so that the category_id won't be visible. But , at that time, I can't write code to Select the category_id of the selected index.
If i am using disconnected approach, I filled the dataset with the Category_Master, and binded it to GridView. But, at that time, I can't hide the category_id from the user. I want to select category_id by clicking on the category_name with out displaying category_id ..?
I'm working on a dynamic table of contents (toc). The toc is generated from data in a sql database. There are 5 sections in the toc and within each of the five sections, there are a varied number of rows. (Section 1 may have 5 rows, while Section 2 has 12 rows). To help differentiate between the sections, I'd like the ability to add some type of grouping in my gridview. So, it would look like below. Do I just add a different gridview for each section, or is there a way to "categorize" the gridview to break up the data with a Section 1 Category
a
b
c
d
e
Section 2 Category
a
b
c
d
e
f
g
h
i....
there is category and under its there are all forum of this category
to do that , I create 2 tables in DB
cat for category have 2 rows ( id,title) and table forum have 3 rows ( id,title,Cat_ID)
I can do it with Php but in asp.net I can't
I read in some article to create nested gridview
i create example using Northwind database so i create a new website and add new ADO.Net Entity Data Model (.edmx) called Northwind.edmx and i add Categories and Products table inside this (.edmx) file
and add new ADO.Net Data Servuce called "ADODataService" and add it as WebReferences called NorthwindService
so i add new web page and drag DropdownList and Gridview as i want to bind Dropdownlist to all categories and when i select category from Dropdownlist bind Gridview to all Products related to this category
so my code
[Code]....
and my code
[Code]....
so when i select category from Dropdownlist nothing happen :(
also you will find commented code in method BindCategory whuch is not work also.
I have a gridview that has the following colums Category, Weight , and an option to delete row. I user would like to be able to highlight two columns in excel Category, Weight and then past them from clipboard to gridview.
View 1 RepliesI have following situation
1. I have gridview which is bind with sql data source column name industry
2. I have checkbox list which has all industry name,
3. I want to pass checkboxlist selected value to sql data souce to filter data in gridview.
I am having a problem .I want to display the book category and subcategories which is fetched from database .
I want to show record like
Example
--------
A
Autobiographies
- Advertising
- Artists
[Code]....
How to show record like this and which control I have to use for this.
im creating advance search for my project and end up with the problem of select statement format for 2category.
here is example:
i have advancesearch that has checkbox wherein you can select multiple checkbox. example is selecting category, for example ihave 5 category as shown below.
Category
News Sports Opinion Editorial Literary i did tried someformats for my select statements to make it work for 2 or more category, but i just cant get the right format of the select statement.
example if i select the following.
if selected is category 'Sports'
it wil work with this: " 'Select * MyTable1 where [Category Title]='Sports' "
if selected are category 'Sports' and 'News'. what must be the format for my selectstatement for 2 or more category in the same fieldname? should it work with this?
" 'Select * MyTable1 where [Category Title]='Sports','News'" no, how could i make it work. what must be the right format?
I have two tables... Laptop category and Laptop details ... Laptop of each category is displayed using Imagebuttons in my website... eg: Dell.HP,Compaq and each category is associated with unique ID like 1 ,2, 3, etc.
Based on this category ID when i click on particular image button it should redirect to another web page ( I ve specified the page in each ImageButton's PostBackUrl property as LaptopDetails.aspx ? catId=1 ....). And in Details page I would like to display the sub models of particular Laptop Category...
for eg Dell has three sub models INSPIRON 1464, INSPIRON 15 and INSPIRON 15R
sub models has to be displayed with image and all the details from the database...
I have a datalist that retreives category names for a knowledge base system I'm working on. When you click to view all the category titles, I want to hide those category titles that don't have any articles associated with that category. So, for example, you click to see all the category titles, but because there isn't any KB articles for "Mice", the "Mice" category isn't visible.
View 2 RepliesI'll try to explain as simple as I can in text what my problem is. I don't see any other way to make my issue clear.
I have a GridView that uses an ObjectDataSource.
The ObjectDataSource has an DataObjectTypeName defined, so I pass/get complete objects or list of objects to/from the data access methods.
The objects I'm working with, let's say we work with Book objects, contain a Title and a Category, BUT the Category is an object itself. When the Select method is called, we get a List of Book objects, which is perfectly displayed, overridden ToString method in the Category objects within the Book objects.
The problem I face is that I can't find a way to update the category in my GridView. What I did already accomplish is:I used a template field in the GridView for the Category so I could use a DropDownList for that field in Edit mode.
I bound the DropDownList to another ObjectDataSource that gives me a list of CategoryObjects.
So when I enter Edit mode... the row shows a nice ddl with the available categories. It even selects the right original category.
So far so good... but when I want to save my new selection, I get an error that a string (the selected category in the ddl) cannot be converted to a Category object (that's what the Book object, that is going to be used for the update, expects).
I'm developing a webshop and need to list products. Each product is displayed in a UserWebControl. I have a method that return the products to be shown. The UserWebCotrol has a product property.What should I use to create the controls on my category page? I need to dynamically create the instances of the UserWbControl and set the product property.
View 4 RepliesWhat would be the best way to handle the following scenario? I have an application where depending on what type of proceeding is selected, only certain input fields should be visible.
There are 33 proceeding types and 14 input fields in total
First case, make one big form with all of the fields and have a dropdown with proceeding type which depending on what is selected, makes certain fields visible?
i have a problem about listing. i have categories that it is added infinite category,subcategory. Table is like that:
id
ustid
kategori
seviye
i want listing like this:
For example when i click "Arac", the list will become like following:
Araç (category)
Otomobil (subcategory)
Motorsiklet (subcategory)
Then .when i click "Otomobil"
Araç
Otomobil
----Fiat
---Audi
---BMW
when i click "Fiat"
Araç
-Otomobil
--Fiat
---Murat
---Şahin
Nested Repeater Issue: Each category list gets populated with the same set of date values rather then being populated with the data associated with that category. Trying to Do: Trying to group FAQ's by category and then list them using the repeaters.
The data is queryed though a business logic layer object that makes a call to the data access layer object. The data access layer object uses linq to sql to return data. There are 3 parameters that are passed into the innerDataSource's ObjectDataSource control to populate the nested repeater control (propID, CatID, isVisible).
With the debugger, the correct data is being returned and written to the nested repeater firing from the nested repeater's ItemDataBound event. Once this event is finished, another event fires and runs the FAQRule object again on the business logic layer which re-populates the nested repeater with the same data for each category. I have 2 repeaters, outerRepater (parent) and innerRepeater(child) with 2 ObjectDataSource controls innerDataSource and outerDataSource. See code below : ASP Page:
<asp:Repeater DataSourceID="outterDataSource" EnableViewState="false" runat="server">
<ItemTemplate>
<%# Eval("Description") + " " + this.Property.PropertyName %>
<asp:Repeater EnableViewState="false" runat="server" DataSourceID="innerDataSource">
<HeaderTemplate>
<ul style="width: 500px">
</HeaderTemplate>
<ItemTemplate>
<div><%# Eval("Question") %></div>
<div><p><%# Eval("Answer") %></p></div>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
<asp:ObjectDataSource ID="innerDataSource"
runat="server"
SelectMethod="FetchFAQSByPrpAndCatID"
TypeName="PropertySite.BusinessRules.FAQRules">
<SelectParameters>......................................
I have the gridview inside another gridview, i want to sort that both gridviews, I don't know how to achieve using asp.net 3.5 visual studio 2008 c# code behind. Following are my aspx page,
<div
id="divclm"
runat="server">
<asp:GridView
ID="claimgrid"
runat="server"
AutoGenerateColumns="False" AllowSorting="True"
Width="100%"
AllowPaging="True"
CssClass="gareahead"
EmptyDataText="No Records To Display"
OnRowDataBound="claimgrid_RowDataBound"
OnRowCreated="claimgrid_RowCreated"
GridLines="Both"
OnPageIndexChanging="claimgrid_PageIndexChanging"
OnSorting="claimgrid_Sorting"
CaptionAlign="Right">
<Columns>
<asp:HyperLinkField
Text="<img id='upimg' src='Styles/Images/appschg.gif'/>"
ItemStyle-Width="10px">
<ItemStyle
Width="10px"
/>
</asp:HyperLinkField>
<asp:BoundField
DataField="name"
HeaderText="Name"
SortExpression="name">
<HeaderStyle
HorizontalAlign="Center"
/>
<ItemStyle
HorizontalAlign="Left"
/>
</asp:BoundField>
<asp:BoundField
DataField="code"
HeaderText="Code"
SortExpression="code">
<HeaderStyle
HorizontalAlign="Center"
/>
<ItemStyle
HorizontalAlign="Left"
/>
</asp:BoundField>
<asp:TemplateField>
<ItemTemplate>
</td></tr>
<tr>
<td
colspan="6"><div
id="<%#Eval("code") %>"
style="display:none;position:relative">
<asp:GridView
ID="Gdclmline1"
runat="server"
AllowPaging="True"
AllowSorting="True"
AutoGenerateColumns="False"
OnSorting="Gdclmline1_Sorting" BorderColor="Green"
BorderStyle="Solid"
BorderWidth="1px"
OnRowDataBound="Gdclmline1_RowDataBound"
OnRowEditing="Gdclmline1_RowEditing" Font-Names="Verdana"
Font-Size="8pt"
Font-Strikeout="False"
OnSelectedIndexChanging="Gdclmline1_SelectedIndexChanging"
OnRowUpdating="Gdclmline1_RowUpdating" PageSize="1000"
RowStyle-Wrap="false"
Width="100%"
CssClass="gareahead"
EmptyDataText="No Records To Display"
GridLines="Both">
<PagerSettings
Mode="NextPreviousFirstLast"
NextPageText="Next"
Position="Top"
PreviousPageText="Prev"
/>
<Columns>
<asp:TemplateField
HeaderText="phone"
SortExpression="phone">
<HeaderStyle
HorizontalAlign="Center"
/>
<ItemStyle
HorizontalAlign="Left"
/>
<ItemTemplate>
<asp:Label
ID="lblphone"
runat="server"
Text='<%#Bind("phone") %>'> </asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField
HeaderText="address1"
SortExpression="address2">
<HeaderStyle
HorizontalAlign="Center"
/>
<ItemStyle
HorizontalAlign="Left"
/>
<ItemTemplate>
<asp:Label
ID="lbladdress1
runat="server"
Text='<%#Bind("address1") %>'> </asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle
CssClass="gr"
Height="100px"
HorizontalAlign="Left"
Wrap="true"/>
<SelectedRowStyle
CssClass="gr"
/> <PagerStyle
CssClass="gareahead"
HorizontalAlign="Left"
Wrap="False"
/> <HeaderStyle
CssClass="ghead"
ForeColor="White"
Wrap="true"
/> </asp:GridView>
</div>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerSettings
Mode="NextPreviousFirstLast"
NextPageText="Next"
Position="Top"
PreviousPageText="Prev"
/>
<HeaderStyle
HorizontalAlign="Center"
VerticalAlign="Middle"
CssClass="ghead"
ForeColor="White"
/>
<RowStyle
CssClass="gr"
/>
<SelectedRowStyle
CssClass="gs"
/>
</asp:GridView>
</div>
that aspx page contains gridview that contain one more gridview inside in it.Now i want to sort out both the grid i.e)claimgrid and Gdclmline1 i want code in c#.
How to create a sub page for each grid view row select?
View 1 RepliesI would like to export the data from GridView to Excel 2007 file (xlsx). Can you please provide me the code.
View 4 RepliesI am sure it must be a way to do this but I don't know how. I have a gridView2 that is called onto the page from a GridView1. I have enabled select on the GridView2 and need to get the values inside the cells. I thought about using SelectedDataKey but I need a way to select the row in the GridView using code.
View 4 Repliesmy input is
sql="SELECT a.ID, a.TGT, a.PAGEID, a.TESTCASE from qc"
my function call is
gridlabel("ID")
GridText(Tgt)
GridCombox("Testcase" )
my output is Gridview add a label with query data Gridview add a Text with query data Gridview add a DropDown with query data
Gridview not binding in code?
[Code]....
[Code]....
I a using Visual Basic, take this into consideration.
I do have the following GriedView:
<asp:GridView
ID="StandardClassifiedsDisplayGridView"
runat="server"
DataSourceID="srcClassifieds"
AutoGenerateColumns="False"
CellPadding="4"
ForeColor="#333333"
AllowPaging="True"
PageSize="100"
DataKeyNames="AutoNumber,UDTIItemDescentFrom">
<Columns>
<asp:TemplateField HeaderText="Picture">
<ItemTemplate>
<asp:ImageButton
ID="ThumbNailImageButton"
runat="server"
Width="75px"
PostBackUrl='<%# string.Concat("~/Classifieds/DetailPage.aspx?AutoNumber=",Convert.ToString(Eval("AutoNumber")),"&FlagForm=NoSubmitted") %>'
ImageUrl='<%# IIF(System.IO.File.Exists(Server.MapPath(string.Format("~/UploadedImagesClassifieds/{0}{1}", Eval("AutoNumber"), "Pic1.jpg"))), string.Format("~/UploadedImagesClassifieds/{0}{1}", Eval("AutoNumber"), "Pic1.jpg"), "~/UploadedImagesClassifieds/NoPicture.gif")
%>'
/>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:BoundField DataField="Category" HeaderText="Category" />
<asp:HyperLinkField HeaderText="Listing Title" DataNavigateUrlFormatString="~/Classifieds/DetailPage.aspx?AutoNumber={0}&FlagForm=NoSubmitted" DataNavigateUrlFields="AutoNumber" DataTextField="ItemTitle"/>
<custom:LongTextField DataField="ListingComment" Width="400px" Height="75px" HeaderText="Listing Comment" HtmlEncode="false" />
<asp:BoundField DataField="EnterDate" HeaderText="Listed on" />
<asp:HyperLinkField HeaderText="See trade history" DataNavigateUrlFormatString='<%# IIF( Eval("UDTIItemDescentFrom").ToString <> "Parent", string.Format("~/Classifieds/SearchPageWithForm.aspx?AutoNumber=", Eval("UDTIItemDescentFrom"),
"&KindOfSearch=ShowMyUDTIGameDownlines"), string.Format("~/Classifieds/SearchPageWithForm.aspx?AutoNumber=", Eval("AutoNumber"), "&KindOfSearch=ShowMyUDTIGameDownlines") ) %>' Text="See trade history"/>
</Columns>
The code inside the PostBackUrl=' and ImageUrl=' are working fine. I tried to do the same, with the code inside the DataNavigateUrlFormatString=' but it is giving me a hard time. It is not working.
I have gridview in my asp.net 3.5 application [C#]. Which looks like this:
[Code]...
I have a button_Click action and inside that I want to read the value of Caption of Gridview.
I am able to read the Cell values but how to read the caption value?
protected void Button1_Click(object sender, EventArgs e)
{
foreach (GridViewRow gvrow in GridView1.Rows)
{
string abc = gvrow.Cells[0].Text.ToString();
// This is how I am reading the cell values which works fine.
// HOW TO READ THE CAPTION VALUE HERE?
}
|}
<GridView id="GridView1" runat="server caption="Want to Read this value in Code Behind">
// columns here.
</GridView>