PDA

View Full Version : سوال: گرفتن مقدار RadioButtonList در تمپلیت گرید



fakhravari
جمعه 05 اسفند 1390, 23:06 عصر
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="true"
RepeatDirection="Horizontal" Width="170px" CellPadding="1" CellSpacing="1"
Font-Names="Tahoma" Font-Overline="False" Font-Size="10pt"
Font-Underline="False">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
</asp:RadioButtonList>
بعد از کلیک مقدارشو چطوری بگیرم به صورت AutoPostBack

mehrdad85
شنبه 06 اسفند 1390, 08:11 صبح
سلام
دوست عزیز منظورتو واضحتر میگی؟
الان مشکل کجاس؟
دقیقا میخای چکار کنی؟

fakhravari
شنبه 06 اسفند 1390, 11:56 صبح
مقدار انتخابیشو میخواهم و همزمان بستبک مقدارش ذخیره بشه در تمپلیت گرید

mehrdad85
شنبه 06 اسفند 1390, 13:05 عصر
با سلام
با استفاده از کد زیر میتونی مقدار انتخابی را استفاده کنی

RadioButtonList1.SelectedValue
auto post back اونو هم که فعال کردی پس کافیه که مقدار انتخابی اون تغییر بکنه در نتیجه صفحت دوباره رفرش میشه

موفق باشی

hjran abdpor
شنبه 06 اسفند 1390, 13:14 عصر
سلام.

<asp:TemplateField HeaderText="Column with ListControls" >
<ItemTemplate>
<asp:DropDownList ID="DropdownList1" OnSelectedIndexChanged="SomethingChanged" AutoPostBack="true" runat="server" >
<asp:ListItem Text="1"></asp:ListItem>
<asp:ListItem Text="2"></asp:ListItem>
</asp:DropDownList>
<asp:RadioButtonList ID="RadioButtonList1" OnSelectedIndexChanged="SomethingChanged" AutoPostBack="true" runat="server">
<asp:ListItem Text="1"></asp:ListItem>
<asp:ListItem Text="2"></asp:ListItem>
</asp:RadioButtonList>
</ItemTemplate>
</asp:TemplateField>


C#

protected void SomethingChanged(object sender, EventArgs e)
{
//in this example this handler is used for both, Dropdownlist and RadiobuttonList
var listControl = (ListControl)sender;
var row = (GridViewRow)listControl.NamingContainer;
var item = listControl.SelectedItem;
//with FindControl on the row you could also find controls in other columns...
}

منبع :http://stackoverflow.com

fakhravari
شنبه 06 اسفند 1390, 14:03 عصر
با سلام
با استفاده از کد زیر میتونی مقدار انتخابی را استفاده کنی

RadioButtonList1.SelectedValue
auto post back اونو هم که فعال کردی پس کافیه که مقدار انتخابی اون تغییر بکنه در نتیجه صفحت دوباره رفرش میشه

موفق باشی

عزیز میگم در گرید .
به صورت عادی که نیست.

fakhravari
شنبه 06 اسفند 1390, 14:04 عصر
سلام.

<asp:TemplateField HeaderText="Column with ListControls" >
<ItemTemplate>
<asp:DropDownList ID="DropdownList1" OnSelectedIndexChanged="SomethingChanged" AutoPostBack="true" runat="server" >
<asp:ListItem Text="1"></asp:ListItem>
<asp:ListItem Text="2"></asp:ListItem>
</asp:DropDownList>
<asp:RadioButtonList ID="RadioButtonList1" OnSelectedIndexChanged="SomethingChanged" AutoPostBack="true" runat="server">
<asp:ListItem Text="1"></asp:ListItem>
<asp:ListItem Text="2"></asp:ListItem>
</asp:RadioButtonList>
</ItemTemplate>
</asp:TemplateField>


C#‎

protected void SomethingChanged(object sender, EventArgs e)
{
//in this example this handler is used for both, Dropdownlist and RadiobuttonList
var listControl = (ListControl)sender;
var row = (GridViewRow)listControl.NamingContainer;
var item = listControl.SelectedItem;
//with FindControl on the row you could also find controls in other columns...
}

منبع :http://stackoverflow.com


ممنون .
حالا برای نمایش مقدار چطوری استفاده کنم.
item.Text; نمیشه

hjran abdpor
شنبه 06 اسفند 1390, 15:26 عصر
ممنون .
حالا برای نمایش مقدار چطوری استفاده کنم.
item.Text; نمیشه


اقای فخاوری شما هستید ؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟:متعجب::متع ب:
اره.

fakhravari
شنبه 06 اسفند 1390, 18:20 عصر
:لبخند::قهقهه:
آخه یه داستانی داره.
من اومدم برای امتیاز دهی از تلریک استفاده کردم.
هرچی گشتم :کف: اخرش کد امتیاز دهی توی گریدشو پیدا نکردم.
اخرش با اعصاب خراب رفتیم توی کار این RadioButtonList که کارمون راه بیوفته فعلا.

fakhravari
یک شنبه 07 اسفند 1390, 20:24 عصر
مشکل حل شد.
http://www.eggheadcafe.com/community/asp-net/17/10420317/update-in-gridview-with-radiobtn.aspx